Submission #211046

# Submission time Handle Problem Language Result Execution time Memory
211046 2020-03-19T06:07:58 Z DodgeBallMan ICC (CEOI16_icc) C++14
100 / 100
204 ms 632 KB
#include "icc.h"
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 105;
 
int n;
int par[N], a[N], b[N], c[N];
vector<int> C[N];
 
int find(int x) { while(x != par[x]) x = par[x]; return x; }
 
void unite(int a, int b) {
    a = find(a), b = find(b);
    if(C[a].size() > C[b].size()) swap(a, b);
    for(int x : C[a]) C[b].emplace_back(x);
    par[a] = b;
}
 
int solve(int pa, int pb, int a[], int b[]) {
    int l = 0, r = pa-1;
    while(l < r) {
        int mid = (l + r) >> 1;
        int pc = 0;
        for(int i = 0; i <= mid; i++) c[pc++] = a[i];
        if(query(pc, pb, c, b)) r = mid;
        else l = mid + 1;
    }
    return a[r];
}
 
void run(int _n) {
    n = _n;
    iota(par, par+N, 0);
    for(int i = 1; i <= n; i++) C[i].emplace_back(i);
    for(int road = 1; road < n; road++) {
        vector<int> vec;
        for(int i = 1; i <= n; i++) if(par[i] == i) vec.emplace_back(i);
        for(int bit = 0; bit <= 7; bit++) {
            int pa = 0, pb = 0;
            for(int i = 0; i < vec.size(); i++) {
                if(i >> bit & 1) for(int x : C[vec[i]]) a[pa++] = x;
                else for(int x : C[vec[i]]) b[pb++] = x;
            }
            if(pa == 0 || pb == 0) continue;
            if(query(pa, pb, a, b)) {
                int u = solve(pa, pb, a, b);
                int v = solve(pb, pa, b, a);
                unite(u, v), setRoad(u, v);
                break;
            }
        }
    }
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:42:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i = 0; i < vec.size(); i++) {
                            ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 512 KB Ok! 99 queries used.
2 Correct 14 ms 512 KB Ok! 94 queries used.
# Verdict Execution time Memory Grader output
1 Correct 60 ms 512 KB Ok! 521 queries used.
2 Correct 51 ms 488 KB Ok! 654 queries used.
3 Correct 52 ms 512 KB Ok! 652 queries used.
# Verdict Execution time Memory Grader output
1 Correct 147 ms 512 KB Ok! 1419 queries used.
2 Correct 171 ms 512 KB Ok! 1595 queries used.
3 Correct 168 ms 512 KB Ok! 1583 queries used.
4 Correct 184 ms 512 KB Ok! 1514 queries used.
# Verdict Execution time Memory Grader output
1 Correct 157 ms 580 KB Ok! 1454 queries used.
2 Correct 175 ms 632 KB Ok! 1584 queries used.
3 Correct 178 ms 512 KB Ok! 1597 queries used.
4 Correct 144 ms 572 KB Ok! 1482 queries used.
# Verdict Execution time Memory Grader output
1 Correct 161 ms 512 KB Ok! 1581 queries used.
2 Correct 161 ms 512 KB Ok! 1573 queries used.
3 Correct 173 ms 608 KB Ok! 1606 queries used.
4 Correct 157 ms 512 KB Ok! 1567 queries used.
5 Correct 147 ms 632 KB Ok! 1427 queries used.
6 Correct 150 ms 512 KB Ok! 1523 queries used.
# Verdict Execution time Memory Grader output
1 Correct 204 ms 512 KB Ok! 1601 queries used.
2 Correct 167 ms 512 KB Ok! 1611 queries used.