# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
62085 |
2018-07-27T12:24:28 Z |
bazsi700 |
ICC (CEOI16_icc) |
C++14 |
|
14 ms |
692 KB |
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL
//13:22
int root[105];
int findroot(int x) {
if(root[x] != x) {
root[x] = findroot(root[x]);
}
return root[x];
}
void join(int a, int b) {
if(rand()%2) {
root[findroot(a)] = findroot(b);
} else {
root[findroot(b)] = findroot(a);
}
}
void run(int n) {
srand(42);
for(int i = 1; i <= n; i++) {
root[i] = i;
}
for(int i = 1; i < n; i++) {
set<int> roots;
vii inroot(n+1,vi());
set<int> gr;
for(int i = 1; i <= n; i++) {
roots.insert(findroot(i));
inroot[root[i]].push_back(i);
gr.insert(i);
}
int xgr,ygr,x,y;
x = -1;
y = -1;
xgr = -1;
for(int curr : roots) {
int a[inroot[curr].size()];
int ind = 0;
for(int el : inroot[curr]) {
gr.erase(el);
a[ind++] = el;
}
ind = 0;
int b[n-inroot[curr].size()];
for(int el : gr) {
b[ind++] = el;
}
int an = query(inroot[curr].size(),n-inroot[curr].size(),a,b);
if(an == 1) {
xgr = curr;
break;
}
for(int el : inroot[curr]) {
gr.insert(el);
}
}
int ind = 0;
int b[n-inroot[xgr].size()];
for(int el : gr) {
b[ind++] = el;
}
vector<int> gr1;
vector<int> gr2;
ind = 0;
for(int el : inroot[xgr]) {
if(ind*2 < inroot[xgr].size()) {
gr1.push_back(el);
} else {
gr2.push_back(el);
}
ind++;
}
while(gr1.size() > 0 && gr2.size() > 0) {
int a[gr1.size()];
ind = 0;
for(int el : gr1) {
a[ind++] = el;
}
int an = query(gr1.size(),n-inroot[xgr].size(),a,b);
if(an) {
gr2.clear();
int ind = 0;
for(int el : gr1) {
if(ind*2 >= gr1.size()) {
gr2.push_back(el);
}
ind++;
}
for(int tim = 0; tim < gr2.size(); tim++) {
gr1.pop_back();
}
} else {
gr1.clear();
int ind = 0;
for(int el : gr2) {
if(ind*2 >= gr2.size()) {
gr1.push_back(el);
}
ind++;
}
for(int tim = 0; tim < gr1.size(); tim++) {
gr2.pop_back();
}
}
}
if(gr1.empty()) {
x = gr2[0];
} else {
x = gr1[0];
}
ind = 0;
for(int el : gr) {
if(ind*2 < gr.size()) {
gr1.push_back(el);
} else {
gr2.push_back(el);
}
ind++;
}
while(gr1.size() > 0 && gr2.size() > 0) {
int bb[gr1.size()];
int a[1];
a[0] = x;
ind = 0;
for(int el : gr1) {
bb[ind++] = el;
}
int an = query(1,gr1.size(),a,bb);
if(an) {
gr2.clear();
int ind = 0;
for(int el : gr1) {
if(ind*2 >= gr1.size()) {
gr2.push_back(el);
}
ind++;
}
for(int tim = 0; tim < gr2.size(); tim++) {
gr1.pop_back();
}
} else {
gr1.clear();
int ind = 0;
for(int el : gr2) {
if(ind*2 >= gr2.size()) {
gr1.push_back(el);
}
ind++;
}
for(int tim = 0; tim < gr1.size(); tim++) {
gr2.pop_back();
}
}
}
if(gr1.empty()) {
y = gr2[0];
} else {
y = gr1[0];
}
join(x,y);
setRoad(x,y);
}
}
Compilation message
icc.cpp: In function 'void run(int)':
icc.cpp:79:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ind*2 < inroot[xgr].size()) {
~~~~~~^~~~~~~~~~~~~~~~~~~~
icc.cpp:97:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ind*2 >= gr1.size()) {
~~~~~~^~~~~~~~~~~~~
icc.cpp:102:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int tim = 0; tim < gr2.size(); tim++) {
~~~~^~~~~~~~~~~~
icc.cpp:109:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ind*2 >= gr2.size()) {
~~~~~~^~~~~~~~~~~~~
icc.cpp:114:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int tim = 0; tim < gr1.size(); tim++) {
~~~~^~~~~~~~~~~~
icc.cpp:126:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ind*2 < gr.size()) {
~~~~~~^~~~~~~~~~~
icc.cpp:146:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ind*2 >= gr1.size()) {
~~~~~~^~~~~~~~~~~~~
icc.cpp:151:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int tim = 0; tim < gr2.size(); tim++) {
~~~~^~~~~~~~~~~~
icc.cpp:158:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(ind*2 >= gr2.size()) {
~~~~~~^~~~~~~~~~~~~
icc.cpp:163:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int tim = 0; tim < gr1.size(); tim++) {
~~~~^~~~~~~~~~~~
icc.cpp:45:11: warning: unused variable 'ygr' [-Wunused-variable]
int xgr,ygr,x,y;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
504 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
612 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
692 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
692 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
692 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
692 KB |
The query sets must be disjoint |
2 |
Halted |
0 ms |
0 KB |
- |