이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "library.h"
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
void Solve(int n) {
if (n == 1) {
Answer({1});
return;
}
vector<vector<int>> g(n + 1);
for (int i = 1; i < n; i++) {
for (int j = i + 1; j <= n; j++) {
vector<int> m(n, 0);
m[i - 1] = m[j - 1] = 1;
if (Query(m) == 1) {
g[i].pb(j);
g[j].pb(i);
}
}
}
int fs = -1;
for (int i = 1; i <= n; i++) {
if (SZ(g[i]) == 1) {
fs = i;
break;
}
}
assert(fs != -1);
vector<int> res = {fs};
int prv = 0, cur = fs;
for (int i = 1; i < n; i++) {
for (int nxt : g[cur]) {
if (nxt != prv) {
res.pb(nxt);
prv = cur;
cur = nxt;
break;
}
}
}
assert(SZ(res) == n);
Answer(res);
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |