Submission #18039

#TimeUsernameProblemLanguageResultExecution timeMemory
18039tncks0121동전 게임 (KOI15_coin)C++14
100 / 100
43 ms2096 KiB
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <deque> #include <utility> #include <bitset> #include <limits.h> #include <time.h> using namespace std; typedef long long ll; typedef unsigned long long llu; typedef double lf; typedef unsigned int uint; typedef long double llf; typedef pair<int, int> pii; int K, C; bool bad (int x, int y, int k) { return abs(x - y) > k; } bool tb[1005][1005]; void solve (int m, int n) { if(tb[m][n]) return; int remaining = K - max(m, n); tb[m][n] = true; if(remaining == 0) return; for(int state = 1; state <= 3; state++) { int x = m, y = n; if(state & 1) ++x; if(x + (remaining - 1) < y || y + remaining < x) { tb[x][y] = true; continue; } if(state & 2) ++y; if(x + (remaining - 1) < y || y + (remaining - 1) < x) { tb[x][y] = true; continue; } solve(x, y); } } int main() { scanf("%d%d", &K, &C); solve(0, 0); while(C--) { int M, N; scanf("%d%d", &M, &N); puts(tb[M][N] ? "1" : "0"); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...