# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
934480 | 2024-02-27T12:11:34 Z | nguyentunglam | Monster Game (JOI21_monster) | C++17 | 59 ms | 692 KB |
#include "monster.h" #include<bits/stdc++.h> using namespace std; mt19937 rng(10184104810471); int rnd(int l, int r) { return l + rng() % (r - l + 1); } vector<int> dnc (vector<int> cur) { if (cur.size() < 2) return cur; vector<int> left, right; for(int i = 0; i < cur.size(); i++) { if (i < cur.size() / 2) left.push_back(cur[i]); else right.push_back(cur[i]); } left = dnc(left); right = dnc(right); // for(int &j : left) cout << j << " "; cout << endl; // for(int &j : right) cout << j << " "; cout << endl; vector<int> ret; for(int i = 0, j = 0; i < left.size() || j < right.size(); ) { if (i < left.size() && (j == right.size() || Query(right[j], left[i]))) { ret.push_back(left[i++]); } else ret.push_back(right[j++]); } return ret; } std::vector<int> Solve(int n) { vector<int> order; for(int i = 0; i < n; i++) order.push_back(i); shuffle(order.begin(), order.end(), rng); order = dnc(order); // for(int &j : order) cout << j << " "; cout << endl; int k = min(12, n); vector<int> win(k); for(int i = 0; i < k; i++) for(int j = i + 1; j < k; j++) { if (Query(order[i], order[j])) win[i]++; else win[j]++; } vector<int> tst; for(int i = 0; i < k; i++) if (win[i] == 1) { tst.push_back(i); // cout << i << endl; } assert(tst.size() == 2); int x = Query(order[tst[0]], order[tst[1]]) ? tst[0] : tst[1]; int i = 0, cnt = 0; vector<int> ans(n); int pre = order[0]; auto expand = [&] () { vector<int> tmp; while (i <= x) tmp.push_back(order[i++]); reverse(tmp.begin(), tmp.end()); pre = tmp.back(); for(int &j : tmp) ans[j] = cnt++; }; expand(); while (x + 1 < n) { for(int y = x + 1; y < n; y++) if (Query(pre, order[y])) { x = y; break; } expand(); } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
16 | Correct | 6 ms | 600 KB | Output is correct |
17 | Correct | 6 ms | 600 KB | Output is correct |
18 | Correct | 8 ms | 444 KB | Output is correct |
19 | Correct | 6 ms | 444 KB | Output is correct |
20 | Correct | 8 ms | 600 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 344 KB | Output is correct |
23 | Correct | 0 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 8 ms | 440 KB | Output is correct |
27 | Correct | 0 ms | 344 KB | Output is correct |
28 | Correct | 0 ms | 344 KB | Output is correct |
29 | Correct | 1 ms | 344 KB | Output is correct |
30 | Correct | 1 ms | 344 KB | Output is correct |
31 | Correct | 0 ms | 600 KB | Output is correct |
32 | Correct | 8 ms | 600 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
16 | Correct | 6 ms | 600 KB | Output is correct |
17 | Correct | 6 ms | 600 KB | Output is correct |
18 | Correct | 8 ms | 444 KB | Output is correct |
19 | Correct | 6 ms | 444 KB | Output is correct |
20 | Correct | 8 ms | 600 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 344 KB | Output is correct |
23 | Correct | 0 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 8 ms | 440 KB | Output is correct |
27 | Correct | 0 ms | 344 KB | Output is correct |
28 | Correct | 0 ms | 344 KB | Output is correct |
29 | Correct | 1 ms | 344 KB | Output is correct |
30 | Correct | 1 ms | 344 KB | Output is correct |
31 | Correct | 0 ms | 600 KB | Output is correct |
32 | Correct | 8 ms | 600 KB | Output is correct |
33 | Correct | 42 ms | 600 KB | Output is correct |
34 | Correct | 40 ms | 600 KB | Output is correct |
35 | Correct | 41 ms | 452 KB | Output is correct |
36 | Correct | 47 ms | 600 KB | Output is correct |
37 | Correct | 42 ms | 692 KB | Output is correct |
38 | Correct | 41 ms | 600 KB | Output is correct |
39 | Correct | 59 ms | 460 KB | Output is correct |
40 | Correct | 58 ms | 444 KB | Output is correct |
41 | Correct | 42 ms | 692 KB | Output is correct |
42 | Correct | 37 ms | 600 KB | Output is correct |
43 | Correct | 40 ms | 600 KB | Output is correct |
44 | Correct | 41 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 600 KB | Output is correct |
2 | Correct | 47 ms | 436 KB | Output is correct |
3 | Correct | 42 ms | 692 KB | Output is correct |
4 | Correct | 45 ms | 688 KB | Output is correct |
5 | Correct | 36 ms | 456 KB | Output is correct |
6 | Correct | 42 ms | 600 KB | Output is correct |
7 | Correct | 33 ms | 460 KB | Output is correct |
8 | Correct | 37 ms | 600 KB | Output is correct |
9 | Correct | 51 ms | 600 KB | Output is correct |
10 | Correct | 50 ms | 460 KB | Output is correct |
11 | Correct | 41 ms | 456 KB | Output is correct |
12 | Correct | 42 ms | 600 KB | Output is correct |
13 | Correct | 33 ms | 600 KB | Output is correct |
14 | Correct | 32 ms | 600 KB | Output is correct |
15 | Correct | 25 ms | 600 KB | Output is correct |
16 | Correct | 25 ms | 692 KB | Output is correct |
17 | Correct | 35 ms | 600 KB | Output is correct |
18 | Correct | 28 ms | 600 KB | Output is correct |