Submission #99309

# Submission time Handle Problem Language Result Execution time Memory
99309 2019-03-02T10:07:54 Z Mercenary ICC (CEOI16_icc) C++14
90 / 100
151 ms 640 KB
#include "icc.h"
#include <bits/stdc++.h>
const int maxn = 105;
using namespace std;

vector<int> P[maxn];

int papa[maxn];

int Cal(vector<int> a , vector<int> b)
{
    assert(a.size() > 0);
    int n = a.size();
    if(n == 1)return a[0];
    vector<int> tmp;
    int mid = n / 2;
    for(int i = 0 ; i < mid ; ++i)tmp.push_back(a[i]);
    if(query(tmp.size(),b.size(),tmp.data(),b.data()))return Cal(tmp,b);
    tmp.clear();
    for(int i = mid ; i < n ; ++i)tmp.push_back(a[i]);
    return Cal(tmp,b);
}

void run(int n)
{
    for(int i = 1 ; i <= n ; ++i)P[i].push_back(i) , papa[i] = i;
    for(int i = n ; i > 1 ; --i)
    {
        vector<int> a , b;
        for(int j = 0 ; j < 10 ; ++j)
        {
            a.clear();b.clear();
            for(int k = 1 ; k <= i ; ++k)
            {
                if((k >> j) & 1)for(int c : P[k])a.push_back(c);
                else for(int c : P[k])b.push_back(c);
            }
            if(a.size() == 0 || b.size() == 0)continue;
            if(query(a.size(),b.size(),a.data(),b.data()))break;
        }
        assert(a.size() > 0 && b.size() > 0);
        int u  = Cal(a , b);
        int v = Cal(b , a);
        setRoad(u,v);
//        cout << u << " " << v << endl;
        u = papa[u];
        v = papa[v];
//        cout << u << " " << v << endl;
        if(u > v)swap(u,v);
        for(int c : P[v])papa[c] = u , P[u].push_back(c);
        if(i != v){
            for(int c : P[i])papa[c] = v;
            swap(P[v],P[i]);
        }
        P[i].clear();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 512 KB Ok! 96 queries used.
2 Correct 10 ms 640 KB Ok! 104 queries used.
# Verdict Execution time Memory Grader output
1 Correct 37 ms 512 KB Ok! 531 queries used.
2 Correct 72 ms 560 KB Ok! 692 queries used.
3 Correct 54 ms 632 KB Ok! 671 queries used.
# Verdict Execution time Memory Grader output
1 Correct 117 ms 600 KB Ok! 1436 queries used.
2 Correct 135 ms 568 KB Ok! 1680 queries used.
3 Correct 124 ms 512 KB Ok! 1613 queries used.
4 Correct 127 ms 640 KB Ok! 1549 queries used.
# Verdict Execution time Memory Grader output
1 Correct 116 ms 512 KB Ok! 1482 queries used.
2 Correct 128 ms 564 KB Ok! 1455 queries used.
3 Correct 149 ms 632 KB Ok! 1636 queries used.
4 Correct 150 ms 636 KB Ok! 1532 queries used.
# Verdict Execution time Memory Grader output
1 Correct 140 ms 560 KB Ok! 1648 queries used.
2 Correct 144 ms 640 KB Ok! 1626 queries used.
3 Correct 151 ms 632 KB Ok! 1653 queries used.
4 Correct 141 ms 512 KB Ok! 1616 queries used.
5 Correct 135 ms 512 KB Ok! 1511 queries used.
6 Correct 145 ms 564 KB Ok! 1569 queries used.
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 512 KB Too many queries! 1639 out of 1625
2 Halted 0 ms 0 KB -