Submission #632776

#TimeUsernameProblemLanguageResultExecution timeMemory
632776flappybirdMemory 2 (JOI16_memory2)C++17
0 / 100
1 ms312 KiB
#include "Memory2_lib.h" #include <bits/stdc++.h> using namespace std; #define MAX 60 int mp[MAX][MAX]; int chk[MAX]; int query(int x, int y) { if (x > y) swap(x, y); if (!~mp[x][y]) return mp[x][y] = Flip(x, y); return mp[x][y]; } void Solve(int T, int N) { memset(mp, -1, sizeof(mp)); vector<int> v; int i; while (1) { for (i = 0; i < N * 2; i++) if (!chk[i]) v.push_back(i); if (v.size() <= 2) { Answer(v[0], v[1], query(v[0], v[1])); return; } int M = v.size(); vector<int> qarr, cnt(N); for (i = 0; i < M; i++) qarr.push_back(query(v[i], v[(i + 1) % M])); int x, mx = 0; for (auto v : qarr) cnt[v]++, mx = max(mx, cnt[v]); for (i = 0; i < N; i++) if (cnt[i] == 4) break; if (i < N) { int k = i; int a, b; a = b = -1; for (i = 0; i < M; i++) if (qarr[i] == qarr[(i + 1) % M] && qarr[i] == k) b = a, a = i; a++, a %= M; b++, b %= M; chk[v[a]] = chk[v[b]] = 1; Answer(v[a], v[b], k); } else { for (i = 0; i < N; i++) if (cnt[i] == mx) break; int k = i; int loc; for (i = 0; i < M; i++) if (qarr[i] == k) break; loc = i; while (qarr[(loc + M - 1) % M] == k) loc = (loc + M - 1) % M; int a, b, c, d; a = loc, b = a + 1, c = b + 1, d = c + 1; a %= M; b %= M; c %= M; d %= M; if (query(v[a], v[d]) == k) { if (query(v[b], v[d]) == k) a = b, c = d; chk[v[a]] = chk[v[c]] = 1; Answer(v[a], v[c], k); } else { chk[v[b]] = chk[v[c]] = 1; Answer(v[b], v[c], k); } } v.clear(); } }

Compilation message (stderr)

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:29:7: warning: unused variable 'x' [-Wunused-variable]
   29 |   int x, mx = 0;
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...