Codeforces Round #614 (Div. 2) C - NEKO's Maze Game

Topic links: http://codeforces.com/contest/1293/problem/C

Title: 2 * n given a map, the map is not the initial magma, you can go,

Given a query q, each interrogation a given point (x, y), each interrogation has the following functions:

(1) If the point is to go, it becomes not go

(2) If the point is not down, then the changes may take

Ask, ask after each role, also can from (1,1) come (2, n).

 

Idea: We can think:

If the second floor there is a point not to go, as long as the point above three points can not go any point, the map can not come to an end.

"If the second floor there is a point not to go, as long as the point above three points at any point you can not go" This sentence can be thought of as the point above

Contribution points three points, then the contribution of the first layer is an arbitrary point [0,3], as long as the first layer is not point away, and the second layer to contribute its value is not 0,

That is, the map can not go through. If the second layer can not go into a point to go, then the contribution of the above three points to -1, or 1 point contribution before subtracting.

. 1 #include <the iostream>
 2 #include <cstdio>
 . 3 #include <algorithm>
 . 4 #include <Queue>
 . 5  the using  namespace STD;
 . 6  
. 7  const  int N = ( int ) 3E5 + 100 ;
 . 8  int App [N << . 1 ] ; // this point whether would take 
. 9  int TOT [N]; // contribution of the first layer 
10  int SUM [ 10 ]; // the contribution of the points 1, 2, 
. 11  
12 is  int main () {
 13  
14      intn-, Q;
 15      Scanf ( " % D% D " , & n-, & Q);
 16      int X, Y;
 . 17      the while (q - ) {
 18 is          Scanf ( " % D% D " , & X, & Y);
 . 19          IF (X> . 1 ) { // the second layer 
20 is              IF {(App [+ n-Y]!) // a second point that would not otherwise exist layer 
21 is                  App [+ n-Y] = . 1 ; // tag is present 
22                  for ( int now max = ( . 1 , (X- . 1 ) * Y- . 1); now <= min((x-1)*y+1,n); ++now){
23                     if(app[now]){//第一层存在
24                         --sum[tot[now]];
25                         ++tot[now];
26                         ++sum[tot[now]];
27                     }
28                     else ++tot[now];
29                 }
30             }else{
31                 app[ n+y ] = 0;
32                  for(int now = max(. 1 , (X- . 1 ) * Y- . 1 ); now <= min ((X- . 1 ) + Y * . 1 , n-); ++ now) {
 33 is                      IF (App [now]) { // first layer is present 
34 is                          - SUM [TOT [now]];
 35                          - TOT [now];
 36                          ++ SUM [TOT [now]];
 37 [                      }
 38 is                      the else - TOT [now];
 39                  }
 40              }
 41 is          } the else { / / first layer point 
42             if(app[x*y]){
43                 app[x*y] = 0;
44                 --sum[tot[x*y]];
45             }
46             else{
47                 app[x*y] = 1;
48                 ++sum[tot[x*y]];
49             }
50         }
51         if(sum[1]+sum[2]+sum[3]) printf("%d__________________________No\n",sum[1]+sum[2]+sum[3]);
52         else printf("__________________________Yes\n");
53     }
54 
55     return 0;
56 }

 

Guess you like

Origin www.cnblogs.com/SSummerZzz/p/12231764.html