Submission #907349

#TimeUsernameProblemLanguageResultExecution timeMemory
907349lightonMinerals (JOI19_minerals)C++17
85 / 100
35 ms3604 KiB
#include "minerals.h" #include <bits/stdc++.h> #define forf(i,a,b) for(int i = a; i<=b; i++) using namespace std; int N,M; set<int> S; vector<int> pre,sec; vector<int> match; int last; vector<int> ran; void dnc(int s, int e , vector<int> v , int d){ if(s==e){ for(int i : v) match[i] = sec[s]; return; } int m = s+e>>1; int now = 0; if(last > m) forf(i,m+1,last){ now = Query(sec[i]); } else forf(i,last+1,m){ now = Query(sec[i]); } vector<int> v1,v2; for(int i : v){ int prv = now; if(v1.size() == (m-s+1)){ v2.push_back(i); continue; } if(v2.size() == (m-s+1)){ v1.push_back(i); continue; } now = Query(pre[i]); if(now == prv) v1.push_back(i); else v2.push_back(i); } last = m; dnc(m+1,e,v2,d+1); last = m; dnc(s,m,v1,d+1); } void Solve(int N) { int now = 0; forf(i,1,2*N) ran.push_back(i); random_shuffle(ran.begin(), ran.end()); ran.insert(ran.begin(),0); forf(i,1,2*N){ int prv = now; if(pre.size() == N){ sec.push_back(ran[i]); Query(ran[i]); continue; } if(sec.size() == N){ pre.push_back(ran[i]); continue; } now = Query(ran[i]); if(now == prv+1){ pre.push_back(ran[i]); } else{ sec.push_back(ran[i]); } } last = N-1; assert(pre.size() == N); match.resize(N); vector<int> v; forf(i,0,N-1) v.push_back(i); dnc(0,N-1,v,1); forf(i,0,N-1) Answer(pre[i],match[i]); }

Compilation message (stderr)

minerals.cpp: In function 'void dnc(int, int, std::vector<int>, int)':
minerals.cpp:18:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   18 |     int m = s+e>>1;
      |             ~^~
minerals.cpp:26:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |         if(v1.size() == (m-s+1)){ v2.push_back(i); continue; }
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:27:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |         if(v2.size() == (m-s+1)){ v1.push_back(i); continue; }
      |            ~~~~~~~~~~^~~~~~~~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:46:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |         if(pre.size() == N){ sec.push_back(ran[i]); Query(ran[i]); continue; }
      |            ~~~~~~~~~~~^~~~
minerals.cpp:47:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |         if(sec.size() == N){ pre.push_back(ran[i]); continue; }
      |            ~~~~~~~~~~~^~~~
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:2:
minerals.cpp:57:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |     assert(pre.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...