# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
101263 |
2019-03-18T05:08:46 Z |
dantoh000 |
ICC (CEOI16_icc) |
C++14 |
|
358 ms |
632 KB |
#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
vi p, rk, sz;
void init(int n){
for(int i = 0; i < n; i++){
p.push_back(i);
rk.push_back(0);
sz.push_back(1);
}
}
int findset(int x){
return p[x] == x ? x : p[x] = findset(p[x]);
}
bool sameset(int i, int j){
return findset(i) == findset(j);
}
void unionset(int i, int j){
int x = findset(i), y = findset(j);
if (x == y) return;
if (rk[x] < rk[y]){
p[x] = y;
sz[y] += sz[x];
}
else{
p[y] = x;
sz[x] += sz[y];
if (rk[x] == rk[y]) rk[x]++;
}
}
void run(int n) {
int cur = 0;
init(n);
vector<int> random;
for (int i = 1; i <= n; i++) random.push_back(i);
random_shuffle(random.begin(),random.end());
int a[1], b[1];
while (cur < n){
for (int i = 0; i < n; i++){
for (int j = i+1; j < n; j++){
//printf("%d %d\n",i,j);
a[0] = random[i], b[0] = random[j];
//printf("%d ",b[0]);
if (sameset(a[0]-1,b[0]-1)) continue;
if (query(1,1,a,b) == 1){
setRoad(a[0],b[0]);
unionset(a[0]-1,b[0]-1);
cur++;
}
}
//printf("done with %d\n",a[0]);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
512 KB |
Ok! 1015 queries used. |
2 |
Correct |
70 ms |
588 KB |
Ok! 1009 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
298 ms |
564 KB |
Number of queries more than 5000 out of 2500 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
358 ms |
560 KB |
Number of queries more than 4500 out of 2250 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
309 ms |
632 KB |
Number of queries more than 4000 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
264 ms |
512 KB |
Number of queries more than 3550 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
285 ms |
564 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |