# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
948861 |
2024-03-18T15:35:32 Z |
phoenix0423 |
ICC (CEOI16_icc) |
C++17 |
|
100 ms |
1108 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
#include "icc.h"
const int maxn = 105;
int n;
int par[maxn];
int root(int x){ return x == par[x] ? x : par[x] = root(par[x]);}
vector<int> comp[maxn];
set<pair<vector<int>, vector<int>>> used;
bool qry(int sa, int sb, vector<int> a, vector<int> b){
int aa[a.size()], bb[b.size()];
copy(a.begin(), a.end(), aa), copy(b.begin(), b.end(), bb);
return query(sa, sb, aa, bb);
}
void run(int _n){
n = _n;
for(int i = 1; i <= n; i++) comp[i].pb(i), par[i] = i;
random_device rd;
mt19937 rng(rd());
for(int rd = 0; rd < n - 1; rd++){
used.clear();
vector<int> cand;
for(int i = 1; i <= n; i++) if(root(i) == i) cand.pb(i);
vector<vector<int>> s(2);
bool c = false;
shuffle(cand.begin(), cand.end(), rng);
int lg = 0;
while(!c){
s[0].clear(), s[1].clear();
for(int i = 0; i < cand.size(); i++){
for(auto u : comp[cand[i]]) s[i >> lg & 1].pb(u);
}
if(!s[0].size() || !s[1].size()) continue;
c = qry(s[0].size(), s[1].size(), s[0], s[1]);
lg++;
}
int l = 0, r = s[0].size() - 1;
while(l != r){
int m = (l + r) / 2;
vector<int> ns;
for(int i = l; i <= m; i++) ns.pb(s[0][i]);
c = qry(ns.size(), s[1].size(), ns, s[1]);
if(c) r = m;
else l = m + 1;
}
vector<int> tmp(1, s[0][l]);
swap(s[0], tmp);
l = 0, r = s[1].size() - 1;
while(l != r){
int m = (l + r) / 2;
vector<int> ns;
for(int i = l; i <= m; i++) ns.pb(s[1][i]);
c = qry(1, ns.size(), s[0], ns);
if(c) r = m;
else l = m + 1;
}
setRoad(s[0][0], s[1][l]);
int a = root(s[0][0]), b = root(s[1][l]);
par[a] = b;
for(auto x : comp[a]) comp[b].pb(x);
}
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:40:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int i = 0; i < cand.size(); i++){
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
600 KB |
Ok! 97 queries used. |
2 |
Correct |
4 ms |
604 KB |
Ok! 100 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
604 KB |
Ok! 525 queries used. |
2 |
Correct |
28 ms |
604 KB |
Ok! 660 queries used. |
3 |
Correct |
27 ms |
600 KB |
Ok! 652 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
600 KB |
Ok! 1411 queries used. |
2 |
Correct |
87 ms |
604 KB |
Ok! 1618 queries used. |
3 |
Correct |
82 ms |
600 KB |
Ok! 1606 queries used. |
4 |
Correct |
84 ms |
604 KB |
Ok! 1514 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
640 KB |
Ok! 1491 queries used. |
2 |
Correct |
77 ms |
640 KB |
Ok! 1470 queries used. |
3 |
Correct |
88 ms |
652 KB |
Ok! 1607 queries used. |
4 |
Correct |
78 ms |
600 KB |
Ok! 1501 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
652 KB |
Ok! 1589 queries used. |
2 |
Correct |
83 ms |
600 KB |
Ok! 1603 queries used. |
3 |
Correct |
86 ms |
604 KB |
Ok! 1631 queries used. |
4 |
Correct |
83 ms |
628 KB |
Ok! 1606 queries used. |
5 |
Correct |
81 ms |
1108 KB |
Ok! 1468 queries used. |
6 |
Correct |
81 ms |
604 KB |
Ok! 1543 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
604 KB |
Ok! 1608 queries used. |
2 |
Correct |
100 ms |
604 KB |
Ok! 1622 queries used. |