Submission #34032

#TimeUsernameProblemLanguageResultExecution timeMemory
34032ToMoClone즐거운 사진 수집 (JOI13_collecting)C++14
100 / 100
2716 ms181336 KiB
/*input 3 2 0 1 0 2 2 3 0 1 1 2 0 3 */ #include <stdio.h> using namespace std; int n, q, sumr[21][1 << 20], sumc[21][1 << 20], col[1 << 20], row[1 << 20], fullrow[21], fullcol[21]; long long ans = 1; int main(){ scanf("%d%d", &n, &q); for(int i = 0; i <= n; ++i) fullrow[i] = fullcol[i] = (1 << (n - i)); while(q--){ int sign, num; scanf("%d%d", &sign, &num); --num; if(sign == 0){ int val = row[num] ? -1 : 1; row[num] ^= 1; for(int i = 0; i <= n; ++i){ // num -= num & (1 << i); if(sumr[i][num] == 0 || sumr[i][num] == (1 << i)) ans += 4 * fullcol[i], --fullrow[i]; sumr[i][num] += val; if(sumr[i][num] == 0 || sumr[i][num] == (1 << i)) ans -= 4 * fullcol[i], ++fullrow[i]; num -= num & (1 << i); } } if(sign == 1){ int val = col[num] ? -1 : 1; col[num] ^= 1; for(int i = 0; i <= n; ++i){ // num -= num & (1 << i); if(sumc[i][num] == 0 || sumc[i][num] == (1 << i)) ans += 4 * fullrow[i], --fullcol[i]; sumc[i][num] += val; if(sumc[i][num] == 0 || sumc[i][num] == (1 << i)) ans -= 4 * fullrow[i], ++fullcol[i]; num -= num & (1 << i); } } printf("%lld\n", ans); } }

Compilation message (stderr)

collecting.cpp: In function 'int main()':
collecting.cpp:18:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &q);
                       ^
collecting.cpp:23:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int sign, num; scanf("%d%d", &sign, &num);
                                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...