Submission #39579

# Submission time Handle Problem Language Result Execution time Memory
39579 2018-01-16T15:56:29 Z igzi ICC (CEOI16_icc) C++14
90 / 100
149 ms 2264 KB
#include <bits/stdc++.h>
#include "icc.h"
 
using namespace std;
 
const int N = 105;
 
int n, par[N], mat[N][N];
set<int>comp;
vector<int>nudes[N];
 
int Find(int at){
    return par[at] == at ? at : par[at] = Find(par[at]);
}
 
void Union(int a, int b){
    int x = Find(a);
    int y = Find(b);
    for(auto u : nudes[y]){
        nudes[x].push_back(u);
    }
    par[y] = x;
    comp.erase(y);
}
 
int fuk[N], tt;
 
int get(int sa, int sb, int a[], int b[]){
    int lo = 0, hi = sb - 1;
    while(lo < hi){
        int mid = (lo + hi) / 2; tt = 0;
        for(int i=lo;i<=mid;i++) fuk[tt] = b[i], ++tt;
        if(query(sa, tt, a, fuk)) hi = mid;
        else lo = mid + 1;
    }
    return b[lo];
}
 
int aa[N], bb[N];
int sa, sb;
 
void run(int _n){
    srand(time(NULL));
    n = _n;
    comp.clear();
    for(int i=1;i<=n;i++){
        par[i] = i;
        comp.insert(i);
        nudes[i].push_back(i);
    }
    int road = n - 1;
    while(road--){
        for(int bit=7;bit>=0;bit--){
            sa = 0, sb = 0;
            for(auto u : comp){
                if(u & (1 << bit)) for(auto v : nudes[u]) aa[sa] = v, ++sa;
                else for(auto v : nudes[u]) bb[sb] = v, ++sb;
            }
            if(sa == 0 || sb == 0) continue;
            if(query(sa, sb, aa, bb)){
                int x = get(sa, sb, aa, bb);
                int y = get(sb, sa, bb, aa);
                Union(x, y);
                setRoad(x, y);
                break;
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2132 KB Ok! 105 queries used.
2 Correct 9 ms 2132 KB Ok! 102 queries used.
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2128 KB Ok! 550 queries used.
2 Correct 39 ms 2136 KB Ok! 665 queries used.
3 Correct 49 ms 2132 KB Ok! 670 queries used.
# Verdict Execution time Memory Grader output
1 Correct 119 ms 2260 KB Ok! 1404 queries used.
2 Correct 139 ms 2264 KB Ok! 1633 queries used.
3 Correct 129 ms 2260 KB Ok! 1520 queries used.
4 Correct 129 ms 2264 KB Ok! 1578 queries used.
# Verdict Execution time Memory Grader output
1 Correct 129 ms 2264 KB Ok! 1554 queries used.
2 Correct 143 ms 2260 KB Ok! 1511 queries used.
3 Correct 129 ms 2264 KB Ok! 1611 queries used.
4 Correct 116 ms 2264 KB Ok! 1447 queries used.
# Verdict Execution time Memory Grader output
1 Correct 149 ms 2260 KB Ok! 1611 queries used.
2 Correct 129 ms 2260 KB Ok! 1625 queries used.
3 Correct 133 ms 2260 KB Ok! 1647 queries used.
4 Correct 129 ms 2264 KB Ok! 1642 queries used.
5 Correct 119 ms 2264 KB Ok! 1535 queries used.
6 Correct 139 ms 2260 KB Ok! 1622 queries used.
# Verdict Execution time Memory Grader output
1 Incorrect 129 ms 2260 KB Too many queries! 1629 out of 1625
2 Halted 0 ms 0 KB -