# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
718250 |
2023-04-03T18:01:30 Z |
stevancv |
ICC (CEOI16_icc) |
C++14 |
|
126 ms |
620 KB |
#include <bits/stdc++.h>
#include "icc.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 100 + 2;
const int inf = 1e9;
vector<int> svi[N];
int aaa[N], bbb[N];
int Query(vector<int> a, vector<int> b) {
int A = a.size(); int B = b.size();
for (int i = 0; i < A; i++) aaa[i] = a[i];
for (int i = 0; i < B; i++) bbb[i] = b[i];
return query(A, B, aaa, bbb);
}
int gazda[N];
void run(int n) {
vector<int> v;
for (int i = 1; i <= n; i++) {
svi[i].push_back(i);
gazda[i] = i;
}
auto Sredi = [&] (vector<int> v) {
vector<int> ret;
for (int i = 0; i < v.size(); i++) {
for (int j : svi[v[i]]) ret.push_back(j);
}
return ret;
};
for (int zz = 0; zz < n - 1; zz++) {
vector<int> v;
for (int i = 1; i <= n; i++) {
if (gazda[i] == i) v.push_back(i);
}
int sz = v.size();
vector<int> a, b;
for (int i = 0; ; i++) {
for (int j = 0; j < sz; j++) {
if ((1 << i) & j) a.push_back(v[j]);
else b.push_back(v[j]);
}
auto aa = Sredi(a); auto bb = Sredi(b);
if (Query(aa, bb) == 1) break;
else {a.clear(); b.clear();}
}
a = Sredi(a); b = Sredi(b);
int l = 0, r = a.size() - 1;
while (l < r) {
int mid = l + r >> 1;
vector<int> tr;
for (int i = 0; i <= mid; i++) tr.push_back(a[i]);
if (Query(tr, b) == 1) r = mid;
else l = mid + 1;
}
int inda = a[r];
l = 0, r = b.size() - 1;
while (l < r) {
int mid = l + r >> 1;
vector<int> tr;
for (int i = 0; i <= mid; i++) tr.push_back(b[i]);
if (Query({inda}, tr) == 1) r = mid;
else l = mid + 1;
}
int indb = b[r];
setRoad(inda, indb);
while (gazda[inda] != inda) inda = gazda[inda];
while (gazda[indb] != indb) indb = gazda[indb];
for (int i : svi[indb]) {
svi[inda].push_back(i);
gazda[i] = inda;
}
svi[indb].clear();
}
}
Compilation message
icc.cpp: In lambda function:
icc.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (int i = 0; i < v.size(); i++) {
| ~~^~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:53:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
53 | int mid = l + r >> 1;
| ~~^~~
icc.cpp:62:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
62 | int mid = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
468 KB |
Ok! 98 queries used. |
2 |
Correct |
7 ms |
428 KB |
Ok! 100 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
468 KB |
Ok! 523 queries used. |
2 |
Correct |
35 ms |
500 KB |
Ok! 659 queries used. |
3 |
Correct |
36 ms |
484 KB |
Ok! 658 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
126 ms |
492 KB |
Ok! 1406 queries used. |
2 |
Correct |
111 ms |
492 KB |
Ok! 1612 queries used. |
3 |
Correct |
107 ms |
508 KB |
Ok! 1577 queries used. |
4 |
Correct |
112 ms |
468 KB |
Ok! 1484 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
488 KB |
Ok! 1500 queries used. |
2 |
Correct |
106 ms |
500 KB |
Ok! 1485 queries used. |
3 |
Correct |
116 ms |
616 KB |
Ok! 1636 queries used. |
4 |
Correct |
106 ms |
492 KB |
Ok! 1456 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
123 ms |
488 KB |
Ok! 1623 queries used. |
2 |
Correct |
121 ms |
496 KB |
Ok! 1608 queries used. |
3 |
Correct |
117 ms |
500 KB |
Ok! 1668 queries used. |
4 |
Correct |
113 ms |
484 KB |
Ok! 1636 queries used. |
5 |
Correct |
103 ms |
620 KB |
Ok! 1423 queries used. |
6 |
Correct |
121 ms |
612 KB |
Ok! 1530 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
126 ms |
488 KB |
Too many queries! 1644 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |