# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
792520 | 2023-07-25T06:17:50 Z | beaconmc | Minerals (JOI19_minerals) | C++14 | 260 ms | 12356 KB |
#include "minerals.h" #include <bits/stdc++.h> typedef long long ll; #define FOR(i, x, y) for(ll i=x; i<y; i++) #define FORNEG(i, x, y) for(ll i=x; i>y; i--) #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL) std::set<ll> machine; int query(int a){ if (machine.count(a)){ machine.erase(a); }else{ machine.insert(a); } return Query(a); } void Solve(int N) { using namespace std; vector<vector<ll>> top; vector<vector<ll>> bot; top.push_back({}); bot.push_back({}); ll cur = 0; FOR(i,1, 2*N+1){ ll result = query(i); if (result == cur + 1){ cur++; top[0].push_back(i); }else{ bot[0].push_back(i); } } ll sus = 0; while (!(top.size() == bot.size() && bot.size() == N)){ sus++; vector<vector<ll>> temp; for (auto&i : bot){ if (i.size() == 1){ temp.push_back(i); continue; } vector<ll> temp2; FOR(j,0,i.size()/2){ temp2.push_back(i[j]); } temp.push_back(temp2); temp2.clear(); FOR(j, i.size()/2, i.size()){ temp2.push_back(i[j]); } temp.push_back(temp2); } bot = temp; temp.clear(); ll ind = 0; FOR(i,0,top.size()){ ll tempflag = -1; if (top[i].size() == 1){ ind += 1; temp.push_back(top[i]); continue; } vector<ll> first; vector<ll> second; ll curval = 0; if (sus%2 == 0){ if (machine.count(bot[ind][0])) tempflag = (sus + 1)%2; else tempflag = sus; }else{ if (machine.count(bot[ind][0])) tempflag = sus; else tempflag = (sus+1)%2; } for (auto&j : bot[ind]){ curval = query(j); } for (auto&j : top[i]){ ll result = query(j); if (result != curval){ curval = result; first.push_back(j); }else{ second.push_back(j); } } if (tempflag%2==1){ temp.push_back(first); temp.push_back(second); } else{ temp.push_back(second); temp.push_back(first); } ind += 2; } top = temp; } FOR(i,0,N){ Answer((int) top[i][0],(int) bot[i][0]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 592 KB | Output is correct |
2 | Correct | 7 ms | 868 KB | Output is correct |
3 | Correct | 14 ms | 1488 KB | Output is correct |
4 | Correct | 33 ms | 2532 KB | Output is correct |
5 | Correct | 71 ms | 4536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 4 ms | 592 KB | Output is correct |
6 | Correct | 7 ms | 868 KB | Output is correct |
7 | Correct | 14 ms | 1488 KB | Output is correct |
8 | Correct | 33 ms | 2532 KB | Output is correct |
9 | Correct | 71 ms | 4536 KB | Output is correct |
10 | Correct | 3 ms | 592 KB | Output is correct |
11 | Correct | 45 ms | 2988 KB | Output is correct |
12 | Correct | 71 ms | 4556 KB | Output is correct |
13 | Correct | 53 ms | 4552 KB | Output is correct |
14 | Correct | 50 ms | 4484 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 4 ms | 592 KB | Output is correct |
6 | Correct | 7 ms | 868 KB | Output is correct |
7 | Correct | 14 ms | 1488 KB | Output is correct |
8 | Correct | 33 ms | 2532 KB | Output is correct |
9 | Correct | 71 ms | 4536 KB | Output is correct |
10 | Correct | 3 ms | 592 KB | Output is correct |
11 | Correct | 45 ms | 2988 KB | Output is correct |
12 | Correct | 71 ms | 4556 KB | Output is correct |
13 | Correct | 53 ms | 4552 KB | Output is correct |
14 | Correct | 50 ms | 4484 KB | Output is correct |
15 | Correct | 231 ms | 11124 KB | Output is correct |
16 | Correct | 222 ms | 11056 KB | Output is correct |
17 | Correct | 157 ms | 11056 KB | Output is correct |
18 | Correct | 146 ms | 10964 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 4 ms | 592 KB | Output is correct |
6 | Correct | 7 ms | 868 KB | Output is correct |
7 | Correct | 14 ms | 1488 KB | Output is correct |
8 | Correct | 33 ms | 2532 KB | Output is correct |
9 | Correct | 71 ms | 4536 KB | Output is correct |
10 | Correct | 3 ms | 592 KB | Output is correct |
11 | Correct | 45 ms | 2988 KB | Output is correct |
12 | Correct | 71 ms | 4556 KB | Output is correct |
13 | Correct | 53 ms | 4552 KB | Output is correct |
14 | Correct | 50 ms | 4484 KB | Output is correct |
15 | Correct | 231 ms | 11124 KB | Output is correct |
16 | Correct | 222 ms | 11056 KB | Output is correct |
17 | Correct | 157 ms | 11056 KB | Output is correct |
18 | Correct | 146 ms | 10964 KB | Output is correct |
19 | Correct | 228 ms | 11980 KB | Output is correct |
20 | Correct | 235 ms | 12032 KB | Output is correct |
21 | Correct | 169 ms | 11976 KB | Output is correct |
22 | Correct | 172 ms | 11032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 4 ms | 592 KB | Output is correct |
6 | Correct | 7 ms | 868 KB | Output is correct |
7 | Correct | 14 ms | 1488 KB | Output is correct |
8 | Correct | 33 ms | 2532 KB | Output is correct |
9 | Correct | 71 ms | 4536 KB | Output is correct |
10 | Correct | 3 ms | 592 KB | Output is correct |
11 | Correct | 45 ms | 2988 KB | Output is correct |
12 | Correct | 71 ms | 4556 KB | Output is correct |
13 | Correct | 53 ms | 4552 KB | Output is correct |
14 | Correct | 50 ms | 4484 KB | Output is correct |
15 | Correct | 231 ms | 11124 KB | Output is correct |
16 | Correct | 222 ms | 11056 KB | Output is correct |
17 | Correct | 157 ms | 11056 KB | Output is correct |
18 | Correct | 146 ms | 10964 KB | Output is correct |
19 | Correct | 228 ms | 11980 KB | Output is correct |
20 | Correct | 235 ms | 12032 KB | Output is correct |
21 | Correct | 169 ms | 11976 KB | Output is correct |
22 | Correct | 172 ms | 11032 KB | Output is correct |
23 | Correct | 252 ms | 12356 KB | Output is correct |
24 | Correct | 236 ms | 11368 KB | Output is correct |
25 | Correct | 160 ms | 12344 KB | Output is correct |
26 | Correct | 149 ms | 11212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 4 ms | 592 KB | Output is correct |
6 | Correct | 7 ms | 868 KB | Output is correct |
7 | Correct | 14 ms | 1488 KB | Output is correct |
8 | Correct | 33 ms | 2532 KB | Output is correct |
9 | Correct | 71 ms | 4536 KB | Output is correct |
10 | Correct | 3 ms | 592 KB | Output is correct |
11 | Correct | 45 ms | 2988 KB | Output is correct |
12 | Correct | 71 ms | 4556 KB | Output is correct |
13 | Correct | 53 ms | 4552 KB | Output is correct |
14 | Correct | 50 ms | 4484 KB | Output is correct |
15 | Correct | 231 ms | 11124 KB | Output is correct |
16 | Correct | 222 ms | 11056 KB | Output is correct |
17 | Correct | 157 ms | 11056 KB | Output is correct |
18 | Correct | 146 ms | 10964 KB | Output is correct |
19 | Correct | 228 ms | 11980 KB | Output is correct |
20 | Correct | 235 ms | 12032 KB | Output is correct |
21 | Correct | 169 ms | 11976 KB | Output is correct |
22 | Correct | 172 ms | 11032 KB | Output is correct |
23 | Correct | 252 ms | 12356 KB | Output is correct |
24 | Correct | 236 ms | 11368 KB | Output is correct |
25 | Correct | 160 ms | 12344 KB | Output is correct |
26 | Correct | 149 ms | 11212 KB | Output is correct |
27 | Incorrect | 260 ms | 11348 KB | Wrong Answer [2] |
28 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 4 ms | 592 KB | Output is correct |
6 | Correct | 7 ms | 868 KB | Output is correct |
7 | Correct | 14 ms | 1488 KB | Output is correct |
8 | Correct | 33 ms | 2532 KB | Output is correct |
9 | Correct | 71 ms | 4536 KB | Output is correct |
10 | Correct | 3 ms | 592 KB | Output is correct |
11 | Correct | 45 ms | 2988 KB | Output is correct |
12 | Correct | 71 ms | 4556 KB | Output is correct |
13 | Correct | 53 ms | 4552 KB | Output is correct |
14 | Correct | 50 ms | 4484 KB | Output is correct |
15 | Correct | 231 ms | 11124 KB | Output is correct |
16 | Correct | 222 ms | 11056 KB | Output is correct |
17 | Correct | 157 ms | 11056 KB | Output is correct |
18 | Correct | 146 ms | 10964 KB | Output is correct |
19 | Correct | 228 ms | 11980 KB | Output is correct |
20 | Correct | 235 ms | 12032 KB | Output is correct |
21 | Correct | 169 ms | 11976 KB | Output is correct |
22 | Correct | 172 ms | 11032 KB | Output is correct |
23 | Correct | 252 ms | 12356 KB | Output is correct |
24 | Correct | 236 ms | 11368 KB | Output is correct |
25 | Correct | 160 ms | 12344 KB | Output is correct |
26 | Correct | 149 ms | 11212 KB | Output is correct |
27 | Incorrect | 260 ms | 11348 KB | Wrong Answer [2] |
28 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 4 ms | 592 KB | Output is correct |
6 | Correct | 7 ms | 868 KB | Output is correct |
7 | Correct | 14 ms | 1488 KB | Output is correct |
8 | Correct | 33 ms | 2532 KB | Output is correct |
9 | Correct | 71 ms | 4536 KB | Output is correct |
10 | Correct | 3 ms | 592 KB | Output is correct |
11 | Correct | 45 ms | 2988 KB | Output is correct |
12 | Correct | 71 ms | 4556 KB | Output is correct |
13 | Correct | 53 ms | 4552 KB | Output is correct |
14 | Correct | 50 ms | 4484 KB | Output is correct |
15 | Correct | 231 ms | 11124 KB | Output is correct |
16 | Correct | 222 ms | 11056 KB | Output is correct |
17 | Correct | 157 ms | 11056 KB | Output is correct |
18 | Correct | 146 ms | 10964 KB | Output is correct |
19 | Correct | 228 ms | 11980 KB | Output is correct |
20 | Correct | 235 ms | 12032 KB | Output is correct |
21 | Correct | 169 ms | 11976 KB | Output is correct |
22 | Correct | 172 ms | 11032 KB | Output is correct |
23 | Correct | 252 ms | 12356 KB | Output is correct |
24 | Correct | 236 ms | 11368 KB | Output is correct |
25 | Correct | 160 ms | 12344 KB | Output is correct |
26 | Correct | 149 ms | 11212 KB | Output is correct |
27 | Incorrect | 260 ms | 11348 KB | Wrong Answer [2] |
28 | Halted | 0 ms | 0 KB | - |