Submission #795455

#TimeUsernameProblemLanguageResultExecution timeMemory
795455SlavicGMinerals (JOI19_minerals)C++17
40 / 100
13 ms1744 KiB
#include <bits/stdc++.h> #include "minerals.h" using namespace std; void Solve(int n) { vector<int> p1, p2; int ans = 0, prevans = -1; for(int i = 1; i <= 2 * n; ++i) { ans = Query(i); if(ans == prevans) { p2.push_back(i); Query(i); } else { p1.push_back(i); } prevans = ans; } assert(p1.size() == n && p2.size() == n); vector<int> pr(n, 0); for(int bit = 0; (1 << bit) < n; ++bit) { for(int i = 0; i < n; ++i) { if(i >> bit & 1) continue; prevans = Query(p1[i]); } for(int i = 0; i < n; ++i) { int ans = Query(p2[i]); if(ans == prevans) { pr[i] += (1 << bit); } Query(p2[i]); } for(int i = 0; i < n; ++i) { if(i >> bit & 1) continue; prevans = Query(p1[i]); } } for(int i = 0; i < n; ++i) { Answer(p2[i], p1[pr[i]]); } } /* 4 1 5 2 6 3 4 7 8 */

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from minerals.cpp:1:
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:18:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     assert(p1.size() == n && p2.size() == n);
      |            ~~~~~~~~~~^~~~
minerals.cpp:18:40: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     assert(p1.size() == n && p2.size() == n);
      |                              ~~~~~~~~~~^~~~
#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...