답안 #197777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197777 2020-01-23T02:15:47 Z sean617 즐거운 사진 수집 (JOI13_collecting) C++
10 / 100
5000 ms 812 KB
#include <iostream>
#include <cstdio>
#define N 2000000
using namespace std;

typedef long long ll;
ll n, m, s[25];
bool r[N], c[N];

bool chr(ll p, ll q) {
	ll i;
	for (i = 1; i < q; i++) {
		if (r[i + p] != r[p]) return 0;
	}
	return 1;
}

bool chc(ll p, ll q) {
	ll i;
	for (i = 1; i < q; i++) {
		if (c[i + p] != c[p]) return 0;
	}
	return 1;
}

ll f(ll p, ll q, ll w) {
	ll i, sz, re = 0;
	if (w == 0) return 1;
	sz = s[w];
	if (chr(p, sz) && chc(q, sz)) return 1;
	re += f(p, q, w - 1);
	re += f(p, q + sz / 2, w - 1);
	re += f(p + sz / 2, q, w - 1);
	re += f(p + sz / 2, q + sz / 2, w - 1);
	return re + 1;
}

int main()
{
	ll i, j, z, x;
	cin >> n >> m;
	s[0] = 1;
	for (i = 1; i <= 20; i++) s[i] = s[i - 1] * 2;
	while (m--) {
		scanf ("%lld %lld", &z, &x);
		x--;
		if (z == 0) r[x] = 1 - r[x];
		else c[x] = 1 - c[x];
		printf("%lld\n", f(0, 0, n));
	}
    return 0;
}

Compilation message

collecting.cpp: In function 'll f(ll, ll, ll)':
collecting.cpp:27:5: warning: unused variable 'i' [-Wunused-variable]
  ll i, sz, re = 0;
     ^
collecting.cpp: In function 'int main()':
collecting.cpp:40:8: warning: unused variable 'j' [-Wunused-variable]
  ll i, j, z, x;
        ^
collecting.cpp:45:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%lld %lld", &z, &x);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 1 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5064 ms 536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5022 ms 812 KB Time limit exceeded
2 Halted 0 ms 0 KB -