# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
950128 |
2024-03-20T05:38:31 Z |
pcc |
CONSUL (info1cup19_consul) |
C++17 |
|
11 ms |
696 KB |
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
/*
/// insert your code
/// for example
if(cnt(kth(1)) > n / 3) say_answer(kth(1));
else say_answer(-1);
*/
map<int,int> kmp,cmp;
int get_idx(int p){
if(kmp.find(p) != kmp.end())return kmp[p];
else return kmp[p] = kth(p);
}
int get_cnt(int k){
if(cmp.find(k) != cmp.end())return cmp[k];
else return cmp[k] = cnt(k);
}
void solve(int N){
kmp.clear();cmp.clear();
vector<int> v;
for(int i = 1;i<=N;i++)v.push_back(i);
srand(time(NULL));
random_shuffle(v.begin(),v.end());
for(int i = 0;i<25;i++){
int now = v[i];
if(get_cnt(get_idx(now))>N/3){
say_answer(get_idx(now));
return;
}
}
say_answer(-1);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
428 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
444 KB |
Output is correct |
2 |
Correct |
11 ms |
444 KB |
Output is correct |
3 |
Correct |
4 ms |
444 KB |
Output is correct |
4 |
Correct |
4 ms |
444 KB |
Output is correct |
5 |
Correct |
7 ms |
440 KB |
Output is correct |
6 |
Correct |
9 ms |
444 KB |
Output is correct |
7 |
Correct |
8 ms |
448 KB |
Output is correct |
8 |
Correct |
9 ms |
440 KB |
Output is correct |
9 |
Correct |
9 ms |
444 KB |
Output is correct |
10 |
Correct |
8 ms |
444 KB |
Output is correct |
11 |
Correct |
9 ms |
440 KB |
Output is correct |
12 |
Correct |
8 ms |
692 KB |
Output is correct |
13 |
Correct |
9 ms |
692 KB |
Output is correct |
14 |
Correct |
7 ms |
696 KB |
Output is correct |