# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52025 |
2018-06-23T09:48:53 Z |
someone_aa |
ICC (CEOI16_icc) |
C++17 |
|
214 ms |
816 KB |
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
const int maxn = 110;
int parent[maxn];
vector<int>comps[maxn];
/*bool query(int a, int b, int aa[], int bb[]) {
for(int i=0;i<a;i++) {
cout<<aa[i]<<" ";
} cout<<"\n";
for(int i=0;i<b;i++) {
cout<<bb[i]<<" ";
} cout<<"\n";
bool answ;
cin>>answ;
return answ;
}
void setRoad(int x, int y) {
cout<<"Road: "<<x<<" "<<y<<"\n";
}*/
int uroot(int x) {
while(x != parent[x]) x = parent[x];
return x;
}
void unite(int x, int y) {
x = uroot(x);
y = uroot(y);
if(x==y) return;
for(int i:comps[x]) {
comps[y].push_back(i);
}
parent[x] = y;
}
bool qq(set<int>a, set<int> b) {
int aa[a.size()], bb[b.size()];
int br = 0;
for(int i:a) aa[br++] = i;
br = 0;
for(int i:b) bb[br++] = i;
return query(a.size(), b.size(), aa, bb);
}
int bin(set<int>a, set<int>b) {
if(b.size() == 1) {
return (*(b.begin()));
}
set<int>fi, si;
int br = 0;
for(int i:b) {
if(br < (b.size()/2)) {
fi.insert(i); br++;
}
else si.insert(i);
}
if(qq(a, si)) return bin(a, si);
else return bin(a, fi);
}
void run(int n) {
set<int>c;
for(int i=1;i<=n;i++) {
parent[i] = i;
comps[i].push_back(i);
}
for(int edges=1;edges<n;edges++) {
for(int i=1;i<=n;i++) {
c.insert(uroot(i));
}
for(int i=0;i<7;i++) {
set<int>a, b;
for(int j:c) {
if(j&(1<<i)) for(int k:comps[j]) a.insert(k);
else for(int k:comps[j]) b.insert(k);
}
if(qq(a, b)) {
int x = bin(a, b);
int y = bin(b, a);
setRoad(x, y);
unite(x, y);
break;
}
}
c.clear();
}
}
/*int main() {
run(4);
return 0;
}*/
Compilation message
icc.cpp: In function 'int bin(std::set<int>, std::set<int>)':
icc.cpp:61:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(br < (b.size()/2)) {
~~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
504 KB |
Ok! 107 queries used. |
2 |
Correct |
8 ms |
612 KB |
Ok! 100 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
708 KB |
Ok! 561 queries used. |
2 |
Correct |
54 ms |
708 KB |
Ok! 659 queries used. |
3 |
Correct |
51 ms |
708 KB |
Ok! 648 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
141 ms |
776 KB |
Ok! 1362 queries used. |
2 |
Correct |
165 ms |
776 KB |
Ok! 1625 queries used. |
3 |
Correct |
128 ms |
776 KB |
Ok! 1330 queries used. |
4 |
Correct |
147 ms |
776 KB |
Ok! 1478 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
145 ms |
784 KB |
Ok! 1413 queries used. |
2 |
Correct |
149 ms |
784 KB |
Ok! 1433 queries used. |
3 |
Correct |
214 ms |
784 KB |
Ok! 1608 queries used. |
4 |
Correct |
151 ms |
816 KB |
Ok! 1309 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
200 ms |
816 KB |
Ok! 1607 queries used. |
2 |
Correct |
162 ms |
816 KB |
Ok! 1627 queries used. |
3 |
Correct |
164 ms |
816 KB |
Ok! 1637 queries used. |
4 |
Correct |
162 ms |
816 KB |
Ok! 1607 queries used. |
5 |
Correct |
198 ms |
816 KB |
Ok! 1425 queries used. |
6 |
Correct |
166 ms |
816 KB |
Ok! 1607 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
165 ms |
816 KB |
Ok! 1619 queries used. |
2 |
Incorrect |
163 ms |
816 KB |
Too many queries! 1626 out of 1625 |