/* 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); */
/* if(a) cout << "FOUND " << a << ' ' << b << endl; */
/* int x, y; */
/* cin >> x >> y; */
/* cout << "NEED TO FIND " << x << ' ' << y << endl; */
/* 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];
int sa, sb;
void run(int _n){
n = _n;
comp.clear();
for(int i=1;i<=n;i++){
par[i] = i;
comp.insert(i);
nudes[i].push_back(i);
}
int road = n - 1;
while(road--){
int fnd = 0;
for(int i=1;i<=n&&!fnd;i++){
for(int j=1;j<=n&&!fnd;j++){
if(Find(i) == Find(j)) continue;
sa = 1, sb = 1;
aa[0] = i;
bb[0] = j;
if(query(sa, sb, aa, bb)){
Union(i, j);
setRoad(i, j);
fnd = 1;
}
}
}
}
}
/* int main(){ */
/* int ff, x, y; */
/* scanf("%d", &ff); */
/* setRoad(0, 0); */
/* run(ff); */
/* return 0; */
/* } */
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
2136 KB |
Ok! 1470 queries used. |
2 |
Correct |
86 ms |
2136 KB |
Ok! 1466 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
319 ms |
2132 KB |
Number of queries more than 5000 out of 2500 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
363 ms |
2136 KB |
Number of queries more than 4500 out of 2250 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
313 ms |
2132 KB |
Number of queries more than 4000 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
296 ms |
2132 KB |
Number of queries more than 3550 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
253 ms |
2140 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |