Submission #250112

#TimeUsernameProblemLanguageResultExecution timeMemory
250112dantoh000Minerals (JOI19_minerals)C++14
90 / 100
67 ms3196 KiB
#include <bits/stdc++.h> #include "minerals.h" using namespace std; vector<int> Q; vector<int> P; int ans[86005]; int ON[86005]; int last; int query(int x){ ON[x] ^= 1; return Query(x); } void solve(vector<int> p, int l, int r, int flag){ if (r == l){ ans[Q[l]] = p[0]; return; } #ifdef debug printf("new <%d,%d> %d\n",l,r,flag); for (auto x : p){ printf("%d ",x); } printf("<- P\n"); for (int i = l; i <= r; i++){ printf("%d ",Q[i]); } printf("<- Q\n"); #endif //assert(p.size() == r-l+1); vector<int> Lp; vector<int> Rp; int n = r-l+1; int mid; mid = (l+r)/2; if (flag){ for (int i = mid+1; i <= r; i++){ last = query(Q[i]); } } else{ for (int i = l; i <= mid; i++){ last = query(Q[i]); } } for (int i = 0; i < n; i++){ int q = query(p[i]); if (q == last){ Lp.push_back(p[i]); } else{ Rp.push_back(p[i]); } if (Lp.size() == mid-l+1 || Rp.size() == r-mid){ //printf("ALL FILLED\n"); for (int j = i+1; j < n; j++){ if (Lp.size() == mid-l+1) Rp.push_back(p[j]); else Lp.push_back(p[j]); } break; } last = q; } #ifdef debug printf("Lp: "); for (auto x : Lp) printf("%d ",x); printf("\n"); printf("Rp: "); for (auto x : Rp) printf("%d ",x); printf("\n"); #endif solve(Lp, l, mid, 1); solve(Rp, mid+1, r, 0); } void Solve(int N) { int last = 0; for (int i = 1; i <= 2*N; i++){ int q = query(i); if (q == last){ Q.push_back(i); } else{ P.push_back(i); } last = q; ON[i] = 1; } srand(time(NULL)); random_shuffle(Q.begin(),Q.end()); random_shuffle(P.begin(),P.end()); solve(P,0,N-1,1); for (auto x: Q){ Answer(x,ans[x]); } }

Compilation message (stderr)

minerals.cpp: In function 'void solve(std::vector<int>, int, int, int)':
minerals.cpp:57:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (Lp.size() == mid-l+1 || Rp.size() == r-mid){
             ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:57:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (Lp.size() == mid-l+1 || Rp.size() == r-mid){
                                     ~~~~~~~~~~^~~~~~~~
minerals.cpp:60:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if (Lp.size() == mid-l+1) Rp.push_back(p[j]);
                     ~~~~~~~~~~^~~~~~~~~~
#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...