#include "minerals.h"
#include <bits/stdc++.h>
#define All(x) x.begin(), x.end()
#define pb emplace_back
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }
void Solve(int N) {
srand(time(NULL));
vector <int> num(2*N);
for (int i = 0; i < 2*N; i++) num[i] = i+1;
random_shuffle(All(num));
deque <int> dq;
vector <int> tmp;
int now = 0, prev = 0;
while (num.size()) {
for (int id : num) {
prev = now;
now = Query(id);
dq.push_back(id);
if (now != prev+1) {
while (true) {
prev = now;
now = Query(dq.front());
if (now == prev-1) {
tmp.pb(dq.front());
dq.pop_front();
} else {
Answer(id, dq.front());
dq.pop_front();
break;
}
}
prev = now;
now = Query(id);
dq.pop_back();
}
}
num = tmp;
tmp.clear();
random_shuffle(All(num));
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
5 ms |
768 KB |
Output is correct |
3 |
Correct |
11 ms |
492 KB |
Output is correct |
4 |
Incorrect |
29 ms |
804 KB |
Wrong Answer [2] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
768 KB |
Output is correct |
7 |
Correct |
11 ms |
492 KB |
Output is correct |
8 |
Incorrect |
29 ms |
804 KB |
Wrong Answer [2] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
768 KB |
Output is correct |
7 |
Correct |
11 ms |
492 KB |
Output is correct |
8 |
Incorrect |
29 ms |
804 KB |
Wrong Answer [2] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
768 KB |
Output is correct |
7 |
Correct |
11 ms |
492 KB |
Output is correct |
8 |
Incorrect |
29 ms |
804 KB |
Wrong Answer [2] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
768 KB |
Output is correct |
7 |
Correct |
11 ms |
492 KB |
Output is correct |
8 |
Incorrect |
29 ms |
804 KB |
Wrong Answer [2] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
768 KB |
Output is correct |
7 |
Correct |
11 ms |
492 KB |
Output is correct |
8 |
Incorrect |
29 ms |
804 KB |
Wrong Answer [2] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
768 KB |
Output is correct |
7 |
Correct |
11 ms |
492 KB |
Output is correct |
8 |
Incorrect |
29 ms |
804 KB |
Wrong Answer [2] |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
5 ms |
768 KB |
Output is correct |
7 |
Correct |
11 ms |
492 KB |
Output is correct |
8 |
Incorrect |
29 ms |
804 KB |
Wrong Answer [2] |
9 |
Halted |
0 ms |
0 KB |
- |