#ifndef kostia
#include"icc.h"
#endif
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<int, int>;
using vpi = vector<pi>;
#ifdef kostia
vpi local_roads;
int local_cur = 0, local_n;
int query(int sa, int sb, int a[], int b[]) {
cout << sa << " " << sb << " :: ";
for(int i = 0; i < sa; i++) cout << a[i] << " "; cout << " - ";
for(int i = 0; i < sb; i++) cout << b[i] << " "; cout << "\n";
for(int i = 0; i < sa; i++) {
for(int j = 0; j < sb; j++) {
for(auto k : local_roads) {
if(a[i]==k.first && b[j]==k.second)
return 1;
if(a[i]==k.second && b[j]==k.first)
return 1;
}
}
}
return 0;
}
void setRoad(int a, int b) {
if(pi{a, b}!=local_roads.back()&&pi{b, a}!=local_roads.back()) {
cout << a << " " << b << "\n";
cout << "BAD";
exit(0);
}
cout << "road " << local_roads.back().first << " " << local_roads.back().second << " guessed.\n";
if(++local_cur==local_n) exit(0);
cin >> a >> b;
local_roads.pb({a, b});
}
#endif
const int maxn = 1e2 + 21;
int n;
int a[maxn], b[maxn];
int q(vi x, vi y) {
if(x.empty()||y.empty()) return 0;
for(int i = 0; i < x.size(); i++) a[i] = x[i];
for(int i = 0; i < y.size(); i++) b[i] = y[i];
return query(x.size(), y.size(), a, b);
}
vi unc[maxn];
void erase(vi& a, int x) {
for(auto &i : a) {
if(i==x) swap(a.back(), i);
}
a.pop_back();
}
void run(int _n) {
n = _n;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
if(i!=j)
unc[i].pb(j);
for(int edge = 1; edge < n; edge++) {
int x = -1, y = -1;
for(int i = 1; y == -1 && i <= n; i++) {
if(q(vi{i}, unc[i])) {
if(x==-1) x = i;
else y = i;
}
}
assert(q(vi{x}, vi{y}));
erase(unc[x], y);
erase(unc[y], x);
setRoad(x, y);
}
}
#ifdef kostia
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << "kostia:\n";
int x, y;
cin >> local_n >> x >> y;
local_roads.pb({x, y});
local_cur = 1;
run(local_n);
return 0;
}
#endif
Compilation message
icc.cpp: In function 'int q(vi, vi)':
icc.cpp:48:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < x.size(); i++) a[i] = x[i];
~~^~~~~~~~~~
icc.cpp:49:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < y.size(); i++) b[i] = y[i];
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
376 KB |
Ok! 224 queries used. |
2 |
Runtime error |
19 ms |
892 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
38 ms |
888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
95 ms |
1012 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
59 ms |
1144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
44 ms |
1144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
323 ms |
676 KB |
Number of queries more than 3250 out of 1625 |
2 |
Halted |
0 ms |
0 KB |
- |