#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home
#include <bits/stdc++.h>
#include <library.h>
using namespace std;
typedef long long ll;
typedef long double ld;
void Solve(int N) {
srand(time(0));
vector < int > M(N);
deque < int > dq;
vector < int > books(N);
iota(books.begin(), books.end(), 0);
random_shuffle(books.begin(), books.end());
dq.push_back(books.back());
bool ok = true;
for(; ok;) {
ok = false;
M[dq.back()] = 1;
for(int i = 0; i < (int)books.size(); ++ i) {
M[books[i]] = 1;
int ans = Query(M);
M[books[i]] = 0;
if(ans == 1) {
dq.push_back(books[i]);
books.erase(books.begin() + i);
ok = true;
break;
}
}
M[dq.back()] = 0;
}
for(ok = true; ok;) {
ok = false;
M[dq.front()] = 1;
for(int i = 0; i < (int)books.size(); ++ i) {
M[books[i]] = 1;
int ans = Query(M);
M[books[i]] = 0;
if(ans == 1) {
dq.push_front(books[i]);
books.erase(books.begin() + i);
ok = true;
break;
}
}
M[dq.front()] = 0;
}
vector < int > res;
for(auto &i : dq) {
res.push_back(i + 1);
}
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
97 ms |
208 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
97 ms |
208 KB |
Wrong Answer [4] |
2 |
Halted |
0 ms |
0 KB |
- |