Submission #16826

# Submission time Handle Problem Language Result Execution time Memory
16826 2015-10-02T11:27:44 Z gs14004 즐거운 사진 수집 (JOI13_collecting) C++14
30 / 100
5000 ms 9912 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int n, q;
int px[1<<20], py[1<<20];

int main(){
    scanf("%d %d",&n,&q);
    for(int i=0; i<q; i++){
        int t, p;
        scanf("%d %d",&t, &p);
        p--;
        if(t) px[p] ^= 1;
        else py[p] ^= 1;
        int ret = 0;
        for(int i=0; i<n; i++){
            int buck = (2 << i);
            int cntx = 0;
            for(int j=0; j<(1<<n); j+=buck){
                int bad = 0;
                for(int k=j; k<j+buck-1; k++){
                    if(px[k] != px[k+1]){
                        bad = 1;
                        break;
                    }
                }
                if(bad) cntx++;
            }
            int cnty = 0;
            for(int j=0; j<(1<<n); j+=buck){
                int bad = 0;
                for(int k=j; k<j+buck-1; k++){
                    if(py[k] != py[k+1]){
                        bad = 1;
                        break;
                    }
                }
                if(bad) cnty++;
            }
            int rcnt = (1 << (n - 1 - i));
            ret += rcnt * rcnt - (rcnt - cntx) * (rcnt - cnty);
        }
        printf("%d\n",ret * 4 + 1);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9912 KB Output is correct
2 Correct 0 ms 9912 KB Output is correct
3 Correct 0 ms 9912 KB Output is correct
4 Correct 0 ms 9912 KB Output is correct
5 Correct 0 ms 9912 KB Output is correct
6 Correct 0 ms 9912 KB Output is correct
7 Correct 1 ms 9912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 9912 KB Output is correct
2 Correct 15 ms 9912 KB Output is correct
3 Correct 36 ms 9912 KB Output is correct
4 Correct 28 ms 9912 KB Output is correct
5 Correct 10 ms 9912 KB Output is correct
6 Correct 36 ms 9912 KB Output is correct
7 Correct 32 ms 9912 KB Output is correct
8 Correct 38 ms 9912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5000 ms 9912 KB Program timed out
2 Halted 0 ms 0 KB -