#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n;
const int MAXN = 2020;
int par[MAXN];
bool comp(int u, int v){
if(Query(0,u,v) == u) return true;
else return false;
}
bool use[MAXN];
bool ban[MAXN];
void Solve(int N) {
n = N;
vector<int> ord;
for(int i = 1; i < n ; i ++ ){
ord.push_back(i);
par[i] = -1;
}
random_shuffle(ord.begin(), ord.end());
int fir;
for(auto nd : ord){
if(par[nd] != -1) continue;
int res;
for(int j = 0 ; j < n; j ++ ){
use[j]=false;
ban[j]=false;
}
for(int j = 1; j < n; j ++ ){
if(j == nd) continue;
res = Query(0, j, nd);
use[res]=true;
}
use[nd]=true;
use[0]=true;
fir = 0;
for(int j = 1; j < n; j ++ ){
if(!use[j]) continue;
if(par[j] != -1){
if(use[par[j]]){
ban[par[j]]=true;
}
}
}
vector<int> ss;
for(int j = 1; j < n; j ++ ){
if(use[j] && par[j] != -1 && ban[j] == false){
fir = j;
}
else if(use[j] && !ban[j]){
ss.push_back(j);
}
}
sort(ss.begin(), ss.end(), comp);
par[ss[0]] = fir;
for(int i = 1; i < ss.size(); i ++ )
par[ss[i]] = ss[i - 1];
}
int l, r;
for(int i = 1; i < n; i ++ ){
l = par[i];
r = i;
if(l > r)
swap(l, r);
Bridge(l, r);
}
}
Compilation message
meetings.cpp: In function 'void Solve(int)':
meetings.cpp:69:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(int i = 1; i < ss.size(); i ++ )
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
416 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
416 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
364 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
416 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
2 ms |
364 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
218 ms |
456 KB |
Output is correct |
28 |
Correct |
206 ms |
452 KB |
Output is correct |
29 |
Correct |
213 ms |
456 KB |
Output is correct |
30 |
Correct |
235 ms |
384 KB |
Output is correct |
31 |
Correct |
221 ms |
456 KB |
Output is correct |
32 |
Correct |
264 ms |
448 KB |
Output is correct |
33 |
Correct |
301 ms |
452 KB |
Output is correct |
34 |
Correct |
279 ms |
460 KB |
Output is correct |
35 |
Correct |
283 ms |
384 KB |
Output is correct |
36 |
Correct |
179 ms |
384 KB |
Output is correct |
37 |
Correct |
39 ms |
384 KB |
Output is correct |
38 |
Correct |
34 ms |
468 KB |
Output is correct |
39 |
Correct |
22 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3094 ms |
512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |