Submission #40035

#TimeUsernameProblemLanguageResultExecution timeMemory
40035cheater2kMemory 2 (JOI16_memory2)C++14
100 / 100
0 ms2024 KiB
#include "Memory2_lib.h" #include <bits/stdc++.h> using namespace std; static const int MAX = 50; static vector<int> pos[MAX]; void Solve(int T, int N){ srand(time(NULL)); vector<int> rem; for (int i = 0; i < 2 * N; ++i) rem.push_back(i); while(rem.size()) { // reset for (int i = 0; i < MAX; ++i) pos[i].clear(); // ask int pivot = rem[rand() % rem.size()]; for (int p : rem) if (p != pivot) { int reply = Flip(p, pivot); pos[reply].push_back(p); } int cur; for (int i = 0; i < MAX; ++i) { if (pos[i].size() == 2) { Answer(min(pos[i][0], pos[i][1]), max(pos[i][0], pos[i][1]), i); rem.erase(find(rem.begin(), rem.end(), pos[i][0])); rem.erase(find(rem.begin(), rem.end(), pos[i][1])); } else if (pos[i].size() & 1) { cur = i; } } if (rem.size() == 2) { // only 2 cards remain Answer(min(rem[0], rem[1]), max(rem[0], rem[1]), cur); break; } } }

Compilation message (stderr)

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:37:57: warning: 'cur' may be used uninitialized in this function [-Wmaybe-uninitialized]
    Answer(min(rem[0], rem[1]), max(rem[0], rem[1]), cur);
                                                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...