# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
797462 | 2023-07-29T12:15:40 Z | beaconmc | Minerals (JOI19_minerals) | C++14 | 303 ms | 15460 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) { ll fuck = 0; 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; } long double ratio = 2; if (i.size() >= 10) ratio = 2.51; vector<ll> temp2; ll cutoff = (long double) i.size() / ratio; FOR(j,0,cutoff){ temp2.push_back(i[j]); } temp.push_back(temp2); temp2.clear(); FOR(j, cutoff, 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 (sus%2 == 0){ if (machine.count(bot[ind][0])) tempflag = (sus + 1)%2; else tempflag = sus%2; }else{ if (machine.count(bot[ind][0])) tempflag = sus%2; else tempflag = (sus+1)%2; } if (top[i].size() == 1){ ind += 1; temp.push_back(top[i]); continue; } if (top[i].size() == 2){ ll idkman = query(bot[ind][0]); ll newman = query(top[i][0]); bool cond = (idkman == newman); if (!(cond^tempflag)){ temp.push_back({top[i][1]}); temp.push_back({top[i][0]}); ind += 2; continue; }else{ temp.push_back({top[i][0]}); temp.push_back({top[i][1]}); ind += 2; continue; } } vector<ll> first; vector<ll> second; ll curval = 0; 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 ms | 208 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 592 KB | Output is correct |
2 | Correct | 8 ms | 976 KB | Output is correct |
3 | Correct | 18 ms | 1704 KB | Output is correct |
4 | Correct | 40 ms | 2920 KB | Output is correct |
5 | Correct | 83 ms | 5188 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 8 ms | 976 KB | Output is correct |
7 | Correct | 18 ms | 1704 KB | Output is correct |
8 | Correct | 40 ms | 2920 KB | Output is correct |
9 | Correct | 83 ms | 5188 KB | Output is correct |
10 | Correct | 4 ms | 592 KB | Output is correct |
11 | Correct | 57 ms | 3700 KB | Output is correct |
12 | Correct | 87 ms | 5164 KB | Output is correct |
13 | Correct | 68 ms | 5128 KB | Output is correct |
14 | Correct | 66 ms | 5076 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 8 ms | 976 KB | Output is correct |
7 | Correct | 18 ms | 1704 KB | Output is correct |
8 | Correct | 40 ms | 2920 KB | Output is correct |
9 | Correct | 83 ms | 5188 KB | Output is correct |
10 | Correct | 4 ms | 592 KB | Output is correct |
11 | Correct | 57 ms | 3700 KB | Output is correct |
12 | Correct | 87 ms | 5164 KB | Output is correct |
13 | Correct | 68 ms | 5128 KB | Output is correct |
14 | Correct | 66 ms | 5076 KB | Output is correct |
15 | Correct | 250 ms | 13416 KB | Output is correct |
16 | Correct | 253 ms | 13380 KB | Output is correct |
17 | Correct | 187 ms | 13444 KB | Output is correct |
18 | Correct | 180 ms | 13780 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 8 ms | 976 KB | Output is correct |
7 | Correct | 18 ms | 1704 KB | Output is correct |
8 | Correct | 40 ms | 2920 KB | Output is correct |
9 | Correct | 83 ms | 5188 KB | Output is correct |
10 | Correct | 4 ms | 592 KB | Output is correct |
11 | Correct | 57 ms | 3700 KB | Output is correct |
12 | Correct | 87 ms | 5164 KB | Output is correct |
13 | Correct | 68 ms | 5128 KB | Output is correct |
14 | Correct | 66 ms | 5076 KB | Output is correct |
15 | Correct | 250 ms | 13416 KB | Output is correct |
16 | Correct | 253 ms | 13380 KB | Output is correct |
17 | Correct | 187 ms | 13444 KB | Output is correct |
18 | Correct | 180 ms | 13780 KB | Output is correct |
19 | Correct | 260 ms | 13384 KB | Output is correct |
20 | Correct | 265 ms | 13444 KB | Output is correct |
21 | Correct | 204 ms | 13652 KB | Output is correct |
22 | Correct | 187 ms | 13152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 8 ms | 976 KB | Output is correct |
7 | Correct | 18 ms | 1704 KB | Output is correct |
8 | Correct | 40 ms | 2920 KB | Output is correct |
9 | Correct | 83 ms | 5188 KB | Output is correct |
10 | Correct | 4 ms | 592 KB | Output is correct |
11 | Correct | 57 ms | 3700 KB | Output is correct |
12 | Correct | 87 ms | 5164 KB | Output is correct |
13 | Correct | 68 ms | 5128 KB | Output is correct |
14 | Correct | 66 ms | 5076 KB | Output is correct |
15 | Correct | 250 ms | 13416 KB | Output is correct |
16 | Correct | 253 ms | 13380 KB | Output is correct |
17 | Correct | 187 ms | 13444 KB | Output is correct |
18 | Correct | 180 ms | 13780 KB | Output is correct |
19 | Correct | 260 ms | 13384 KB | Output is correct |
20 | Correct | 265 ms | 13444 KB | Output is correct |
21 | Correct | 204 ms | 13652 KB | Output is correct |
22 | Correct | 187 ms | 13152 KB | Output is correct |
23 | Correct | 265 ms | 13828 KB | Output is correct |
24 | Correct | 281 ms | 13828 KB | Output is correct |
25 | Correct | 203 ms | 13724 KB | Output is correct |
26 | Correct | 203 ms | 13556 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 8 ms | 976 KB | Output is correct |
7 | Correct | 18 ms | 1704 KB | Output is correct |
8 | Correct | 40 ms | 2920 KB | Output is correct |
9 | Correct | 83 ms | 5188 KB | Output is correct |
10 | Correct | 4 ms | 592 KB | Output is correct |
11 | Correct | 57 ms | 3700 KB | Output is correct |
12 | Correct | 87 ms | 5164 KB | Output is correct |
13 | Correct | 68 ms | 5128 KB | Output is correct |
14 | Correct | 66 ms | 5076 KB | Output is correct |
15 | Correct | 250 ms | 13416 KB | Output is correct |
16 | Correct | 253 ms | 13380 KB | Output is correct |
17 | Correct | 187 ms | 13444 KB | Output is correct |
18 | Correct | 180 ms | 13780 KB | Output is correct |
19 | Correct | 260 ms | 13384 KB | Output is correct |
20 | Correct | 265 ms | 13444 KB | Output is correct |
21 | Correct | 204 ms | 13652 KB | Output is correct |
22 | Correct | 187 ms | 13152 KB | Output is correct |
23 | Correct | 265 ms | 13828 KB | Output is correct |
24 | Correct | 281 ms | 13828 KB | Output is correct |
25 | Correct | 203 ms | 13724 KB | Output is correct |
26 | Correct | 203 ms | 13556 KB | Output is correct |
27 | Correct | 286 ms | 14656 KB | Output is correct |
28 | Correct | 286 ms | 14792 KB | Output is correct |
29 | Correct | 224 ms | 14980 KB | Output is correct |
30 | Correct | 206 ms | 14516 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 8 ms | 976 KB | Output is correct |
7 | Correct | 18 ms | 1704 KB | Output is correct |
8 | Correct | 40 ms | 2920 KB | Output is correct |
9 | Correct | 83 ms | 5188 KB | Output is correct |
10 | Correct | 4 ms | 592 KB | Output is correct |
11 | Correct | 57 ms | 3700 KB | Output is correct |
12 | Correct | 87 ms | 5164 KB | Output is correct |
13 | Correct | 68 ms | 5128 KB | Output is correct |
14 | Correct | 66 ms | 5076 KB | Output is correct |
15 | Correct | 250 ms | 13416 KB | Output is correct |
16 | Correct | 253 ms | 13380 KB | Output is correct |
17 | Correct | 187 ms | 13444 KB | Output is correct |
18 | Correct | 180 ms | 13780 KB | Output is correct |
19 | Correct | 260 ms | 13384 KB | Output is correct |
20 | Correct | 265 ms | 13444 KB | Output is correct |
21 | Correct | 204 ms | 13652 KB | Output is correct |
22 | Correct | 187 ms | 13152 KB | Output is correct |
23 | Correct | 265 ms | 13828 KB | Output is correct |
24 | Correct | 281 ms | 13828 KB | Output is correct |
25 | Correct | 203 ms | 13724 KB | Output is correct |
26 | Correct | 203 ms | 13556 KB | Output is correct |
27 | Correct | 286 ms | 14656 KB | Output is correct |
28 | Correct | 286 ms | 14792 KB | Output is correct |
29 | Correct | 224 ms | 14980 KB | Output is correct |
30 | Correct | 206 ms | 14516 KB | Output is correct |
31 | Correct | 291 ms | 15056 KB | Output is correct |
32 | Correct | 303 ms | 15236 KB | Output is correct |
33 | Correct | 222 ms | 15460 KB | Output is correct |
34 | Correct | 244 ms | 14864 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 0 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 | 8 ms | 976 KB | Output is correct |
7 | Correct | 18 ms | 1704 KB | Output is correct |
8 | Correct | 40 ms | 2920 KB | Output is correct |
9 | Correct | 83 ms | 5188 KB | Output is correct |
10 | Correct | 4 ms | 592 KB | Output is correct |
11 | Correct | 57 ms | 3700 KB | Output is correct |
12 | Correct | 87 ms | 5164 KB | Output is correct |
13 | Correct | 68 ms | 5128 KB | Output is correct |
14 | Correct | 66 ms | 5076 KB | Output is correct |
15 | Correct | 250 ms | 13416 KB | Output is correct |
16 | Correct | 253 ms | 13380 KB | Output is correct |
17 | Correct | 187 ms | 13444 KB | Output is correct |
18 | Correct | 180 ms | 13780 KB | Output is correct |
19 | Correct | 260 ms | 13384 KB | Output is correct |
20 | Correct | 265 ms | 13444 KB | Output is correct |
21 | Correct | 204 ms | 13652 KB | Output is correct |
22 | Correct | 187 ms | 13152 KB | Output is correct |
23 | Correct | 265 ms | 13828 KB | Output is correct |
24 | Correct | 281 ms | 13828 KB | Output is correct |
25 | Correct | 203 ms | 13724 KB | Output is correct |
26 | Correct | 203 ms | 13556 KB | Output is correct |
27 | Correct | 286 ms | 14656 KB | Output is correct |
28 | Correct | 286 ms | 14792 KB | Output is correct |
29 | Correct | 224 ms | 14980 KB | Output is correct |
30 | Correct | 206 ms | 14516 KB | Output is correct |
31 | Correct | 291 ms | 15056 KB | Output is correct |
32 | Correct | 303 ms | 15236 KB | Output is correct |
33 | Correct | 222 ms | 15460 KB | Output is correct |
34 | Correct | 244 ms | 14864 KB | Output is correct |
35 | Incorrect | 241 ms | 10936 KB | Wrong Answer [2] |
36 | Halted | 0 ms | 0 KB | - |