# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
717880 |
2023-04-02T17:59:41 Z |
stevancv |
ICC (CEOI16_icc) |
C++14 |
|
24 ms |
500 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);
}
void Nadji(vector<int> a, vector<int> b) {
int l = 0, r = a.size() - 2, xx = a.back();
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) {
xx = a[mid];
r = mid - 1;
}
else l = mid + 1;
}
l = 0, r = b.size() - 2;
int yy = b.back();
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(tr, {xx}) == 1) {
yy = b[mid];
r = mid - 1;
}
else l = mid + 1;
}
setRoad(xx, yy);
}
int gazda[N];
void run(int n) {
vector<int> v;
for (int i = 1; i <= n; i++) {
svi[i].push_back(i);
gazda[i] = 1;
}
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] == 1) v.push_back(i);
}
int sz = v.size();
vector<int> a, b;
while (1) {
random_shuffle(v.begin(), v.end());
for (int i = 0; i < sz / 2; i++) a.push_back(v[i]);
for (int i = sz / 2; i < sz; i++) b.push_back(v[i]);
auto aa = Sredi(a); auto bb = Sredi(b);
if (Query(aa, bb) == 1) break;
else {a.clear(); b.clear();}
}
int l = 0, r = a.size() - 2, inda = a.back();
auto bb = Sredi(b);
while (l <= r) {
int mid = l + r >> 1;
vector<int> tr;
for (int i = 0; i <= mid; i++) tr.push_back(a[i]);
auto ttr = Sredi(tr);
if (Query(ttr, bb) == 1) {
inda = a[mid];
r = mid - 1;
}
else l = mid + 1;
}
l = 0, r = b.size() - 2;
int indb = b.back();
auto aa = Sredi({inda});
while (l <= r) {
int mid = l + r >> 1;
vector<int> tr;
for (int i = 0; i <= mid; i++) tr.push_back(b[i]);
auto ttr = Sredi(tr);
if (Query(aa, tr) == 1) {
indb = b[mid];
r = mid - 1;
}
else l = mid + 1;
}
Nadji(svi[inda], svi[indb]);
if (inda > indb) swap(inda, indb);
for (int i : svi[indb]) {
svi[inda].push_back(i);
gazda[i] = 0;
}
svi[indb].clear();
}
}
Compilation message
icc.cpp: In function 'void Nadji(std::vector<int>, std::vector<int>)':
icc.cpp:23:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
23 | int mid = l + r >> 1;
| ~~^~~
icc.cpp:35:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
35 | int mid = l + r >> 1;
| ~~^~~
icc.cpp: In lambda function:
icc.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for (int i = 0; i < v.size(); i++) {
| ~~^~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:78:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
78 | int mid = l + r >> 1;
| ~~^~~
icc.cpp:92:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
92 | int mid = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
468 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
500 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
436 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |