# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
23374 |
2017-05-07T16:23:44 Z |
rubabredwan |
ICC (CEOI16_icc) |
C++14 |
|
363 ms |
2136 KB |
/* Bismillahir Rahmanir Rahim */
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
const int N = 105;
int n, par[N], mat[N][N];
set<int>comp;
vector<int>nudes[N];
int Find(int at){
return par[at] == at ? at : par[at] = Find(par[at]);
}
void Union(int a, int b){
int x = Find(a);
int y = Find(b);
for(auto u : nudes[y]){
nudes[x].push_back(u);
}
par[y] = x;
comp.erase(y);
}
// void setRoad(int a, int b){
// if(a) Union(a, b);
// int x, y;
// cin >> x >> y;
// mat[x][y] = 1;
// mat[y][x] = 1;
// }
// int query(int sa, int sb, int a[], int b[]){
// for(int i=0;i<sa;i++){
// for(int j=0;j<sb;j++){
// if(mat[a[i]][b[j]]) return true;
// }
// }
// return false;
// }
int fuk[N], tt;
int get(int sa, int sb, int a[], int b[]){
int lo = 0, hi = sb - 1;
while(lo < hi){
int mid = (lo + hi) / 2; tt = 0;
for(int i=lo;i<=mid;i++) fuk[tt] = b[i], ++tt;
if(query(sa, tt, a, fuk)) hi = mid;
else lo = mid + 1;
}
return b[lo];
}
int aa[N], bb[N];
void run(int _n){
n = _n;
comp.clear();
for(int i=1;i<=n;i++){
par[i] = i;
comp.insert(i);
nudes[i].clear();
nudes[i].push_back(i);
}
int road = n - 1;
while(road--){
while(1){
int sa = 0, sb = 0;
for(auto u : comp){
if(rand() & 1){
for(auto v : nudes[u]){
aa[sa] = v;
++sa;
}
}
else{
for(auto v : nudes[u]){
bb[sb] = v;
++sb;
}
}
}
if(query(sa, sb, aa, bb)){
Union(get(sa, sb, aa, bb), get(sb, sa, bb, aa));
break;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
183 ms |
2132 KB |
Number of queries more than 3000 out of 1500 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
326 ms |
2136 KB |
Number of queries more than 5000 out of 2500 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
363 ms |
2132 KB |
Number of queries more than 4500 out of 2250 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
336 ms |
2132 KB |
Number of queries more than 4000 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
289 ms |
2132 KB |
Number of queries more than 3550 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
259 ms |
2132 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |