# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
585723 |
2022-06-29T09:10:47 Z |
박상훈(#8384) |
ICC (CEOI16_icc) |
C++14 |
|
102 ms |
492 KB |
#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct DSU{
int path[111];
void init(int n){for (int i=1;i<=n;i++) path[i] = i;}
int find(int s){
if (s==path[s]) return s;
return path[s] = find(path[s]);
}
void merge(int s, int v){
s = find(s), v = find(v);
if (s==v) return;
path[s] = v;
}
}dsu;
int A[111], B[111];
int Q(vector<int>::iterator a1, vector<int>::iterator a2, vector<int>::iterator b1, vector<int>::iterator b2){
int sa = a2 - a1, sb = b2 - b1;
for (int i=0;i<sa;i++) A[i] = *(a1+i);
for (int i=0;i<sb;i++) B[i] = *(b1+i);
return query(sa, sb, A, B);
}
vector<int> _A, _B, V[111];
int myquery(int mx, int k){
_A.clear(), _B.clear();
for (int i=0;i<mx;i++){
if (i&(1<<k)){
for (auto &x:V[i]) _B.push_back(x);
}
else{
for (auto &x:V[i]) _A.push_back(x);
}
}
return Q(_A.begin(), _A.end(), _B.begin(), _B.end());
}
int _search(vector<int> A, vector<int> B){
int l = 1, r = (int)A.size()-1, ans = (int)A.size()-1;
while(l<=r){
int m = (l+r)>>1;
if (Q(A.begin(), A.begin()+m+1, B.begin(), B.end())) ans = m, r = m-1;
else l = m+1;
}
return A[ans];
}
void run(int n){
dsu.init(n);
for (int z=0;z<n-1;z++){
vector<int> idx;
for (int i=1;i<=n;i++) idx.push_back(dsu.find(i));
sort(idx.begin(), idx.end());
idx.erase(unique(idx.begin(), idx.end()), idx.end());
for (int i=0;i<=n;i++) V[i].clear();
for (int i=1;i<=n;i++) V[lower_bound(idx.begin(), idx.end(), dsu.find(i)) - idx.begin()].push_back(i);
int mx = idx.size();
int k = 0;
for (;;k++){
if (myquery(mx, k)) break;
}
int x = _search(_A, _B);
int y = _search(_B, {x});
setRoad(x, y);
dsu.merge(x, y);
}
}
//int main(){}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
99 ms |
492 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
102 ms |
480 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
484 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
480 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |