Submission #250216

#TimeUsernameProblemLanguageResultExecution timeMemory
250216dantoh000Minerals (JOI19_minerals)C++14
90 / 100
55 ms2804 KiB
#include <bits/stdc++.h> using namespace std; #include "minerals.h" using namespace std; vector<int> Q; vector<int> P; int ans[86005]; void solve(vector<int> p, int l, int r, int flag){ if (r == l){ //printf("%d -> %d\n",Q[l],p[0]); Answer(Q[l],p[0]); return; } #ifdef debug 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 m = l +(r-l)*0.5; int last; for (int i = l; i <= m; i++){ last = Query(Q[i]); } for (int i = 0; i < n; i++){ if (Rp.size() == r-m) Lp.push_back(p[i]); else if (Lp.size() == m-l+1) Rp.push_back(p[i]); else{ int q = Query(p[i]); if ((q == last) != flag){ Lp.push_back(p[i]); } else{ Rp.push_back(p[i]); } last = q; } } solve(Lp, l, m, !flag); solve(Rp, m+1, r, flag); } 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; } solve(P,0,N-1,1); }

Compilation message (stderr)

minerals.cpp: In function 'void solve(std::vector<int>, int, int, int)':
minerals.cpp:36:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (Rp.size() == r-m) Lp.push_back(p[i]);
             ~~~~~~~~~~^~~~~~
minerals.cpp:37:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         else if (Lp.size() == m-l+1) Rp.push_back(p[i]);
                  ~~~~~~~~~~^~~~~~~~
#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...