This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1010;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))
int N;
vector<int> getmsk (vector<int> v) {
vector<int> m(N);
for (int i : v) {
m[i] = true;
}
return m;
}
bool has[MAXN];
int query() {
return Query(vector<int> (has, has + N));
}
void Solve (int nnn) {
N = nnn;
deque<int> dq = {0};
has[0] = true;
for (int i = 1; i < N; i++) {
//find the one adjacent
vector<int> poss;
for (int j = 1; j < N; j++) {
if (!has[j]) {
poss.push_back(j);
}
}
int val = -1;
for (int j = 0; j + 1 < poss.size(); j++) {
int x = poss[j];
has[x] = true;
if (query() == 1) {
val = x;
break;
}
has[x] = false;
}
if (val == -1) {
val = poss.back();
has[val] = true;
}
//which one is it now?
bool isbck = false;
if (dq.size() > 1) {
//maybe it's true!
if (Query(getmsk(vector<int> {dq.back(), val})) == 1) {
isbck = true;
}
}
if (isbck) {
dq.push_back(val);
} else {
dq.push_front(val);
}
}
for (int &x : dq) {
x++;
}
Answer(vector<int> (all(dq)));
}
Compilation message (stderr)
library.cpp: In function 'void Solve(int)':
library.cpp:47:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j + 1 < poss.size(); j++) {
~~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |