Submission #503210

#TimeUsernameProblemLanguageResultExecution timeMemory
503210leinad2Minerals (JOI19_minerals)C++17
100 / 100
117 ms40000 KiB
#include "minerals.h" #include<bits/stdc++.h> using namespace std; vector<int>A; vector<vector<int> >v; vector<int>bit; int a; void solve() { bool flag=true; for(int i=0;i<v.size();i++)if(v[i].size()>=2)flag=false; if(flag)return; int sz=0; int x=0; for(int i=0;i<v.size();i++) { if(v[i].size()==1) { sz++; continue; } int cnt=round((double)v[i].size()*0.31465); if(bit[i]==1) { for(int j=sz+v[i].size()-cnt;j<sz+v[i].size();j++)a=Query(A[j]); } else { for(int j=sz;j<sz+cnt;j++)a=Query(A[j]); } sz+=v[i].size(); } vector<vector<int> >V; vector<int>Bit; for(int i=0;i<v.size();i++) { vector<int>Fi, Se; if(v[i].size()==1) { V.push_back(v[i]); Bit.push_back(bit[i]); continue; } int cnt=round((double)v[i].size()*0.31465); for(auto p:v[i]) { if(bit[i]==1&&v[i].size()-cnt==Fi.size())Se.push_back(p); else if(bit[i]==1&&cnt==Se.size())Fi.push_back(p); else if(bit[i]==0&&cnt==Fi.size())Se.push_back(p); else if(bit[i]==0&&v[i].size()-cnt==Se.size())Fi.push_back(p); else { int b=Query(p); if(a!=b)Se.push_back(p); else Fi.push_back(p); a=b; } } V.push_back(Fi); V.push_back(Se); Bit.push_back(1); Bit.push_back(0); } v=V; bit=Bit; solve(); } void Solve(int N) { vector<int>A, B; for(int i=1;i<=2*N;i++) { int b=Query(i); if(a!=b)A.push_back(i); else B.push_back(i); a=b; } ::A=A; v={B}; bit={1}; solve(); vector<int>ans; for(int i=0;i<v.size();i++)if(v[i].size())ans.push_back(v[i][0]); for(int i=0;i<N;i++)Answer(A[i], ans[i]); }

Compilation message (stderr)

minerals.cpp: In function 'void solve()':
minerals.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<v.size();i++)if(v[i].size()>=2)flag=false;
      |                 ~^~~~~~~~~
minerals.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
minerals.cpp:25:43: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             for(int j=sz+v[i].size()-cnt;j<sz+v[i].size();j++)a=Query(A[j]);
      |                                          ~^~~~~~~~~~~~~~~
minerals.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
minerals.cpp:48:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             else if(bit[i]==1&&cnt==Se.size())Fi.push_back(p);
      |                                ~~~^~~~~~~~~~~
minerals.cpp:49:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             else if(bit[i]==0&&cnt==Fi.size())Se.push_back(p);
      |                                ~~~^~~~~~~~~~~
minerals.cpp:14:9: warning: unused variable 'x' [-Wunused-variable]
   14 |     int x=0;
      |         ^
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:83:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for(int i=0;i<v.size();i++)if(v[i].size())ans.push_back(v[i][0]);
      |                 ~^~~~~~~~~
#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...