Submission #315042

#TimeUsernameProblemLanguageResultExecution timeMemory
315042thtsshz_bgwrswhCONSUL (info1cup19_consul)C++17
100 / 100
45 ms384 KiB
#pragma GCC optimize("Ofast") #include "grader.h" #include<algorithm> #include<random> #include<vector> #include<utility> #include<map> using namespace std; int order[1005]; map<int,int> m; vector<pair<int,int>> q; void solve(int n){ int i; for(i=1;i<=n;i++) order[i]=i; random_shuffle(order+1,order+n+1); m.clear(); for(i=1;i<=25;i++) m[kth(order[i])]++; q.clear(); for(auto x:m) q.emplace_back(x.second,x.first); sort(q.begin(),q.end()); reverse(q.begin(),q.end()); if(n<=50){ int ans=0,v; for(i=0;i<25&&i<(int)q.size();i++){ int temp=cnt(q[i].second); if(temp>ans){ ans=temp; v=q[i].second; } } if(ans>n/3) say_answer(v); else say_answer(-1); } else{ int ans=0,v; for(i=0;i<35&&i<(int)q.size();i++){ int temp=cnt(q[i].second); if(temp>ans){ ans=temp; v=q[i].second; } } if(ans>n/3) say_answer(v); else say_answer(-1); } }

Compilation message (stderr)

consul.cpp: In function 'void solve(int)':
consul.cpp:49:14: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |    say_answer(v);
      |    ~~~~~~~~~~^~~
consul.cpp:35:14: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |    say_answer(v);
      |    ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...