# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
116951 |
2019-06-14T08:20:09 Z |
minhtung0404 |
ICC (CEOI16_icc) |
C++17 |
|
42 ms |
460 KB |
//https://oj.uz/problem/view/CEOI16_icc
#include<bits/stdc++.h>
#include "icc.h"
const int N = 105;
using namespace std;
int pset[N];
int find(int i) {return ((pset[i] == i) ? i : pset[i] = find(pset[i]));}
void dsu(int i, int j){
i = find(i); j = find(j);
if (i == j) return;
pset[i] = j;
}
bool query(vector <int> &a, vector <int> &b){
int A[N], B[N], siza = a.size(), sizb = b.size();
for (int i = 0; i < siza; i++) A[i] = a[i];
for (int i = 0; i < sizb; i++) B[i] = b[i];
return query(siza, sizb, A, B);
}
void find(vector <int>&a, vector <int>& b){
if (a.size() == 1 && b.size() == 1) return;
if (a.size() == 1 && b.size() != 1){
find(b, a);
return;
}
int siz = (int)a.size() / 2;
vector <int> x;
for (int i = 0; i < siz; i++) x.push_back(a[i]);
if (query(x, b)){
a = x;
}
else{
x.clear();
for (int i = siz; i < a.size(); i++) x.push_back(a[i]);
a = x;
find(a, b);
}
}
void cal(vector <int>& a, vector <int>& b){
find(a, b);
setRoad(a[0], b[0]);
dsu(a[0], b[0]);
}
void run(int n){
while (1){
vector <int> A;
for (int i = 1; (1 << i) <= n; i++){
vector <int> a, b;
for (int j = 1; j <= n; j++){
if ((find(j) >> i)&1){
a.push_back(j);
}
else{
b.push_back(j);
}
}
if (query(a, b)){
cal(a, b); break;
}
}
}
}
Compilation message
icc.cpp: In function 'void find(std::vector<int>&, std::vector<int>&)':
icc.cpp:39:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = siz; i < a.size(); i++) x.push_back(a[i]);
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
384 KB |
Number of queries more than 3000 out of 1500 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
384 KB |
Number of queries more than 5000 out of 2500 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
460 KB |
Number of queries more than 4500 out of 2250 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
384 KB |
Number of queries more than 4000 out of 2000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
384 KB |
Number of queries more than 3550 out of 1775 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
448 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |