# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
597471 |
2022-07-16T04:57:32 Z |
1bin |
ICC (CEOI16_icc) |
C++14 |
|
125 ms |
496 KB |
#include <bits/stdc++.h>
#include "icc.h"
#include <cassert>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
const int NMAX = 105;
int par[NMAX], a[NMAX], b[NMAX], sza, szb;
int find(int x){ return par[x] == -1 ? x : par[x] = find(par[x]);}
vector<int> v[NMAX];
void run(int n){
memset(par, -1, sizeof(par));
for(int i = 1; i <= n; i++) v[i].emplace_back(i);
int sz = n;
for(int i = 0; i < n - 1; i++, sz--){
vector<int> arr;
for(int i = 1; i <= n; i++)
if(par[i] == -1) arr.emplace_back(i);
for(int bit = 0; 1 << bit < sz; bit++){
sza = szb = 0;
for(int j = 0; j < sz; j++){
if(j & (1 << bit)) {
for(auto x : v[arr[j]]) a[sza++] = x;
}
else{
for(auto x : v[arr[j]]) b[szb++] = x;
}
}
if(1 << bit + 1 >= sz || query(sza, szb, a, b)){
int l = 0, r = sza - 1, m, x, y;
while(l < r){
m = (l + r) >> 1;
if(query(m + 1, szb, a, b)) r = m;
else l = m + 1;
}
x = a[l];
l = 0; r = szb - 1;
while(l < r){
m = (l + r) >> 1;
if(query(sza, m + 1, a, b)) r = m;
else l = m + 1;
}
y = b[l];
setRoad(x, y);
x = find(x); y = find(y);
if(v[x].size() < v[y].size()) swap(x, y);
for(int t : v[y]) v[x].emplace_back(t);
par[y] = x;
break;
}
}
}
return;
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:35:25: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
35 | if(1 << bit + 1 >= sz || query(sza, szb, a, b)){
| ~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
468 KB |
Ok! 98 queries used. |
2 |
Correct |
4 ms |
468 KB |
Ok! 96 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
468 KB |
Ok! 534 queries used. |
2 |
Correct |
30 ms |
480 KB |
Ok! 616 queries used. |
3 |
Correct |
29 ms |
468 KB |
Ok! 606 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
480 KB |
Ok! 1430 queries used. |
2 |
Correct |
106 ms |
468 KB |
Ok! 1513 queries used. |
3 |
Correct |
104 ms |
496 KB |
Ok! 1589 queries used. |
4 |
Correct |
102 ms |
484 KB |
Ok! 1468 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
484 KB |
Ok! 1503 queries used. |
2 |
Correct |
105 ms |
480 KB |
Ok! 1492 queries used. |
3 |
Correct |
101 ms |
496 KB |
Ok! 1537 queries used. |
4 |
Correct |
101 ms |
488 KB |
Ok! 1494 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
484 KB |
Ok! 1522 queries used. |
2 |
Correct |
113 ms |
492 KB |
Ok! 1513 queries used. |
3 |
Correct |
103 ms |
484 KB |
Ok! 1550 queries used. |
4 |
Correct |
112 ms |
484 KB |
Ok! 1573 queries used. |
5 |
Correct |
104 ms |
468 KB |
Ok! 1460 queries used. |
6 |
Correct |
125 ms |
488 KB |
Ok! 1554 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
496 KB |
Ok! 1537 queries used. |
2 |
Correct |
100 ms |
488 KB |
Ok! 1513 queries used. |