#include "lokahia.h"
#include <bits/stdc++.h>
using namespace std;
int FindBase(int N){
vector<vector<int> > s, t, de;
vector<int> la;
for(int i = 0; i < N; i++)
s.push_back({i});
while(s.size() > 1){
for(int i = 1; i < s.size(); i += 2){
if(CollectRelics(s[i - 1][0], s[i][0]) == -1){
de.push_back(s[i - 1]);
de.push_back(s[i]);
} else {
for(int& x : s[i - 1])
s[i].push_back(x);
t.push_back(s[i]);
}
}
if(s.size() & 1){
de.push_back(s.back());
la = s.back();
}
swap(s, t);
t.clear();
}
if(s.empty()) s.push_back(la);
if(s[0].empty()) return -1;
int res = 0;
int root = s[0][0];
int sz = 1;
for(int i = 0; i < N; i++){
if(root == i) continue;
int rrr = CollectRelics(root, i);
if(rrr != -1){
res = max(rrr, res);
sz++;
}
}
if(sz > N / 2) return res;
return -1;
}
Compilation message
lokahia.cpp: In function 'int FindBase(int)':
lokahia.cpp:13:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i < s.size(); i += 2){
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
640 KB |
Correct : C = 188 |
2 |
Correct |
6 ms |
640 KB |
Correct : C = 192 |
3 |
Correct |
6 ms |
688 KB |
Correct : C = 177 |
4 |
Partially correct |
7 ms |
728 KB |
Partially correct : C = 306 |
5 |
Correct |
6 ms |
640 KB |
Correct : C = 195 |
6 |
Partially correct |
8 ms |
640 KB |
Partially correct : C = 323 |
7 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 331 |
8 |
Correct |
6 ms |
472 KB |
Correct : C = 7 |
9 |
Correct |
6 ms |
640 KB |
Correct : C = 100 |
10 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 320 |
11 |
Correct |
6 ms |
640 KB |
Correct : C = 231 |
12 |
Correct |
6 ms |
512 KB |
Correct : C = 60 |
13 |
Correct |
6 ms |
640 KB |
Correct : C = 191 |
14 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 329 |
15 |
Correct |
7 ms |
640 KB |
Correct : C = 235 |
16 |
Correct |
7 ms |
640 KB |
Correct : C = 131 |
17 |
Partially correct |
6 ms |
720 KB |
Partially correct : C = 321 |
18 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 396 |
19 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 320 |
20 |
Correct |
9 ms |
640 KB |
Correct : C = 105 |
21 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 323 |
22 |
Partially correct |
7 ms |
848 KB |
Partially correct : C = 392 |
23 |
Partially correct |
8 ms |
640 KB |
Partially correct : C = 336 |
24 |
Correct |
6 ms |
512 KB |
Correct : C = 0 |
25 |
Correct |
7 ms |
640 KB |
Correct : C = 199 |
26 |
Correct |
6 ms |
640 KB |
Correct : C = 188 |
27 |
Correct |
7 ms |
640 KB |
Correct : C = 297 |