Submission #101244

# Submission time Handle Problem Language Result Execution time Memory
101244 2019-03-18T04:19:03 Z dantoh000 ICC (CEOI16_icc) C++14
0 / 100
334 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);
    int a[1], b[1];
    while (cur < n){
        for (a[0] = 1; a[0] <= n; a[0]++){
            for (b[0] = 1; b[0] <= n; 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);
                }
            }
        }
    }
}

# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 632 KB Too many queries! 1834 out of 1500
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 305 ms 512 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 564 KB Number of queries more than 4500 out of 2250
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 292 ms 564 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 246 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 255 ms 592 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -