Submission #99312

# Submission time Handle Problem Language Result Execution time Memory
99312 2019-03-02T10:25:12 Z Mercenary ICC (CEOI16_icc) C++14
90 / 100
161 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)
    {
        sort(P + 1 , P + i + 1);
        for(int j = 1 ; j <= i ; ++j)
            for(int c : P[j])papa[c] = j;
        vector<int> a , b;
        for(int j = 0 ; j < 8 ; ++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 640 KB Ok! 96 queries used.
2 Correct 14 ms 640 KB Ok! 104 queries used.
# Verdict Execution time Memory Grader output
1 Correct 37 ms 596 KB Ok! 531 queries used.
2 Correct 47 ms 560 KB Ok! 692 queries used.
3 Correct 49 ms 632 KB Ok! 671 queries used.
# Verdict Execution time Memory Grader output
1 Correct 130 ms 512 KB Ok! 1435 queries used.
2 Correct 143 ms 512 KB Ok! 1680 queries used.
3 Correct 136 ms 512 KB Ok! 1613 queries used.
4 Correct 133 ms 600 KB Ok! 1559 queries used.
# Verdict Execution time Memory Grader output
1 Correct 126 ms 556 KB Ok! 1473 queries used.
2 Correct 130 ms 580 KB Ok! 1508 queries used.
3 Correct 137 ms 560 KB Ok! 1635 queries used.
4 Correct 115 ms 632 KB Ok! 1532 queries used.
# Verdict Execution time Memory Grader output
1 Correct 133 ms 564 KB Ok! 1650 queries used.
2 Correct 161 ms 600 KB Ok! 1626 queries used.
3 Correct 142 ms 632 KB Ok! 1655 queries used.
4 Correct 134 ms 556 KB Ok! 1610 queries used.
5 Correct 133 ms 632 KB Ok! 1492 queries used.
6 Correct 141 ms 632 KB Ok! 1578 queries used.
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 564 KB Too many queries! 1639 out of 1625
2 Halted 0 ms 0 KB -