"bzoj3671" [Noi2014] random number generator

Source: Internet
Author: User

Prioritize the processing of arrays in the way it describes

And then, in order to get as many small numbers as possible in the sequence,

So 1 is a must to appear, in order to make the whole sequence of the order of the dictionary after the smallest.

We thought, if 2 could be in this series, it'd be better.

But 2 may not be in this series, that is, 2 walk 1 is impossible to go to the place, you can not walk 2.

So from small to large enumeration numbers, if the current number can go, the output, and then mark all the nodes that go out of this node can not go.

#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include < Cstdio> #include <cmath>using namespace std; typedef long Long LL; #define N 5010 LL seed,a,b,c,d; int n,m,ask;int x, y; int Arr[n*n],g[n][n];int ans[n<<2]; BOOL V[n][n]; int work () {return seed= (a*seed*seed%d+b*seed%d+c)%d;} int main () {scanf ("%lld%lld%lld%lld%lld%d%d%d", &seed,&amp    ; a,&b,&c,&d,&m,&n,&ask);    for (int i=1;i<=n*m;i++) Arr[i]=i,swap (Arr[i],arr[work ()%i+1]);          for (int i=1;i<=ask;i++) {scanf ("%d%d", &x,&y);      Swap (arr[x],arr[y]);    } for (int i=1;i<=m;i++) for (int j=1;j<=n;j++) g[i][j]=arr[(i-1) *n+j];    for (int i=1;i<=m;i++) for (int j=1;j<=n;j++) arr[g[i][j]]= (i-1) *n+j;          for (int i=1;i<=n*m;i++) {x=arr[i]/n+1-(arr[i]%n==0);        y=arr[i]-(x-1) *n;   if (!v[x][y]) {if (i!=1)             Putchar (");              printf ("%d", I);                         for (int j=x+1;j<=m;j++) for (int k=y-1;k;k--) {if (V[j][k])                      Break                  V[j][k]=true;  } for (int j=x-1;j;j--) for (int k=y+1;k<=n;k++) {if                      (V[j][k]) break;                  V[j][k]=true; }}} return 0;}

  

"bzoj3671" [Noi2014] random number generator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.