Submission #843727

#TimeUsernameProblemLanguageResultExecution timeMemory
843727mickey080929Memory 2 (JOI16_memory2)C++17
60 / 100
1 ms600 KiB
#include "Memory2_lib.h" #include <bits/stdc++.h> using namespace std; int ret[110]; int cnt[110]; int chk[110]; vector<int> ans[110]; void Solve(int T, int N) { int r = 2 * N; while (true) { if (r == 2) { int x = -1, y = -1; for (int i=0; i<2*N; i++) { if (!chk[i]) { if (x == -1) x = i; else y = i; } } ans[Flip(x, y)] = {x, y}; break; } int idx = rand() % r; int pv; for (int i=0; i<2*N; i++) { if (!chk[i]) { if (idx == 0) { pv = i; break; } idx --; } } for (int i=0; i<N; i++) cnt[i] = 0; for (int i=0; i<2*N; i++) { if (pv == i || chk[i]) continue; ret[i] = Flip(pv, i); cnt[ret[i]] ++; } int cur = -1; for (int i=0; i<N; i++) { if (cnt[i] & 1) { cur = i; break; } } for (int i=0; i<2*N; i++) { if (pv == i || chk[i]) continue; if (ret[i] != cur) { ans[ret[i]].push_back(i); chk[i] = 1; r --; } } } for (int i=0; i<N; i++) { Answer(ans[i][0], ans[i][1], i); } return; }

Compilation message (stderr)

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:39:26: warning: 'pv' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |             ret[i] = Flip(pv, i);
      |                      ~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...