# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
99314 |
2019-03-02T10:30:53 Z |
Mercenary |
ICC (CEOI16_icc) |
C++14 |
|
179 ms |
652 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 + 1) / 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,greater<vector<int>>());
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 |
10 ms |
512 KB |
Ok! 95 queries used. |
2 |
Correct |
9 ms |
512 KB |
Ok! 93 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
512 KB |
Ok! 528 queries used. |
2 |
Correct |
48 ms |
576 KB |
Ok! 657 queries used. |
3 |
Correct |
63 ms |
508 KB |
Ok! 642 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
512 KB |
Ok! 1373 queries used. |
2 |
Correct |
131 ms |
512 KB |
Ok! 1596 queries used. |
3 |
Correct |
134 ms |
512 KB |
Ok! 1596 queries used. |
4 |
Correct |
133 ms |
652 KB |
Ok! 1474 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
166 ms |
636 KB |
Ok! 1464 queries used. |
2 |
Correct |
146 ms |
512 KB |
Ok! 1471 queries used. |
3 |
Correct |
122 ms |
512 KB |
Ok! 1547 queries used. |
4 |
Correct |
113 ms |
632 KB |
Ok! 1489 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
568 KB |
Ok! 1553 queries used. |
2 |
Correct |
117 ms |
568 KB |
Ok! 1521 queries used. |
3 |
Correct |
130 ms |
512 KB |
Ok! 1571 queries used. |
4 |
Correct |
134 ms |
560 KB |
Ok! 1540 queries used. |
5 |
Correct |
126 ms |
556 KB |
Ok! 1455 queries used. |
6 |
Correct |
179 ms |
604 KB |
Ok! 1534 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
600 KB |
Ok! 1544 queries used. |
2 |
Correct |
134 ms |
512 KB |
Ok! 1590 queries used. |