# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
99310 |
2019-03-02T10:20:54 Z |
Mercenary |
ICC (CEOI16_icc) |
C++14 |
|
200 ms |
632 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)
{
random_shuffle(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 |
11 ms |
512 KB |
Ok! 105 queries used. |
2 |
Correct |
9 ms |
512 KB |
Ok! 107 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
512 KB |
Ok! 535 queries used. |
2 |
Correct |
51 ms |
512 KB |
Ok! 689 queries used. |
3 |
Correct |
64 ms |
512 KB |
Ok! 692 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
133 ms |
512 KB |
Ok! 1424 queries used. |
2 |
Correct |
155 ms |
564 KB |
Ok! 1695 queries used. |
3 |
Correct |
155 ms |
604 KB |
Ok! 1600 queries used. |
4 |
Correct |
163 ms |
632 KB |
Ok! 1528 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
157 ms |
632 KB |
Ok! 1510 queries used. |
2 |
Correct |
126 ms |
600 KB |
Ok! 1533 queries used. |
3 |
Correct |
138 ms |
600 KB |
Ok! 1647 queries used. |
4 |
Correct |
142 ms |
512 KB |
Ok! 1503 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
154 ms |
576 KB |
Ok! 1641 queries used. |
2 |
Correct |
157 ms |
512 KB |
Ok! 1660 queries used. |
3 |
Correct |
200 ms |
632 KB |
Ok! 1678 queries used. |
4 |
Correct |
135 ms |
632 KB |
Ok! 1632 queries used. |
5 |
Correct |
148 ms |
512 KB |
Ok! 1514 queries used. |
6 |
Correct |
153 ms |
512 KB |
Ok! 1596 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
161 ms |
600 KB |
Too many queries! 1656 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |