# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
101245 |
2019-03-18T04:27:04 Z |
dantoh000 |
ICC (CEOI16_icc) |
C++14 |
|
334 ms |
604 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){
bool done = false;
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);
done = true;
cur++;
break;
}
}
//printf("done with %d\n",a[0]);
if (done) break;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
512 KB |
Ok! 1015 queries used. |
2 |
Correct |
60 ms |
584 KB |
Ok! 1009 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
293 ms |
552 KB |
Number of queries more than 5000 out of 2500 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
334 ms |
604 KB |
Number of queries more than 4500 out of 2250 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
326 ms |
560 KB |
Number of queries more than 4000 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
271 ms |
556 KB |
Number of queries more than 3550 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
245 ms |
512 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |