#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();
}
int sz = 0;
if(s.empty()) s.push_back(la);
else sz = s[0].size();
if(s[0].empty()) return -1;
int res = 0;
for(int i = 1; i < s[0].size(); i++){
res = max(res, CollectRelics(s[0][i], s[0][0]));
}
for(auto& x : de){
int rrr = CollectRelics(x[0], s[0][0]);
if(rrr != -1){
res = max(res, rrr);
for(int i = 1; i < x.size(); i++){
rrr = CollectRelics(x[i], s[0][0]);
res = max(res, rrr);
}
sz += x.size();
}
}
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){
~~^~~~~~~~~~
lokahia.cpp:41:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i < s[0].size(); i++){
~~^~~~~~~~~~~~~
lokahia.cpp:49:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i < x.size(); i++){
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 396 |
2 |
Correct |
6 ms |
640 KB |
Correct : C = 60 |
3 |
Correct |
7 ms |
640 KB |
Correct : C = 105 |
4 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 328 |
5 |
Correct |
6 ms |
640 KB |
Correct : C = 194 |
6 |
Correct |
6 ms |
640 KB |
Correct : C = 188 |
7 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 321 |
8 |
Incorrect |
6 ms |
640 KB |
Wrong |
9 |
Correct |
6 ms |
512 KB |
Correct : C = 189 |
10 |
Correct |
6 ms |
564 KB |
Correct : C = 188 |
11 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 314 |
12 |
Incorrect |
6 ms |
640 KB |
Wrong |
13 |
Incorrect |
6 ms |
640 KB |
Wrong |
14 |
Correct |
5 ms |
512 KB |
Correct : C = 7 |
15 |
Correct |
6 ms |
640 KB |
Correct : C = 231 |
16 |
Correct |
6 ms |
512 KB |
Correct : C = 0 |
17 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 392 |
18 |
Incorrect |
6 ms |
640 KB |
Wrong |
19 |
Correct |
6 ms |
640 KB |
Correct : C = 100 |
20 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 316 |
21 |
Incorrect |
6 ms |
640 KB |
Wrong |
22 |
Correct |
7 ms |
640 KB |
Correct : C = 131 |
23 |
Correct |
6 ms |
640 KB |
Correct : C = 235 |
24 |
Incorrect |
7 ms |
640 KB |
Wrong |
25 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 331 |
26 |
Correct |
6 ms |
640 KB |
Correct : C = 190 |
27 |
Partially correct |
7 ms |
640 KB |
Partially correct : C = 318 |