Submission #836142

#TimeUsernameProblemLanguageResultExecution timeMemory
836142unnickMinerals (JOI19_minerals)C++14
40 / 100
13 ms1744 KiB
#include "minerals.h" #include <vector> using namespace std; void Solve(int N) { vector<int> fst; vector<int> snd; int prev = 0; for (int i = 1; i <= N*2; i++) { int tmp = Query(i); if (tmp > prev) fst.push_back(i); prev = tmp; } for (int i = 1; i <= N*2; i++) { int tmp = Query(i); if (tmp < prev) snd.push_back(i); prev = tmp; } int baseline; for (int i = 0; i < N; i++) { if (i&1) baseline = Query(fst[i]); } vector<int> ids(N, 0); for (int pd = 1; pd < N; pd <<= 1) { if (pd > 1) { for (int i = 0; i < N; i++) { if ((i&pd) ^ ((i<<1)&pd)) baseline = Query(fst[i]); } } for (int i = 0; i < N; i++) { int bit = !(Query(snd[i]) - baseline); ids[i] += bit * pd; Query(snd[i]); } } for (int i = 0; i < N; i++) { Answer(fst[ids[i]], snd[i]); } }

Compilation message (stderr)

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:34:17: warning: 'baseline' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |       int bit = !(Query(snd[i]) - baseline);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...