Submission #1009883

# Submission time Handle Problem Language Result Execution time Memory
1009883 2024-06-28T07:13:03 Z thangdz2k7 The Collection Game (BOI21_swaps) C++17
100 / 100
4 ms 1572 KB
#include <bits/stdc++.h>
#include "swaps.h"

using namespace std;

vector <int> ans;

void solve(int n, int v){
    for (int i = 1; i <= n; ++ i) ans.push_back(i);

    for (int t = 0; t < 9; ++ t){
        for (int k = t; k >= 0; -- k){
            vector <pair <int, int>> ask;
            for (int i = 0; i < n; ++ i){
                if (((i >> k) & 1) != (k - t != 0)) continue;
                if (i + (1 << k) >= n) continue;
                if ((i + (1 << k) >> (t + 1)) != (i >> (t + 1))) continue;
                schedule(ans[i], ans[i + (1 << k)]);
                ask.push_back({i, i + (1 << k)});
            }
            vector <int> res = visit();
            for (int i = 0; i < res.size(); ++ i){
                if (!res[i]) swap(ans[ask[i].first], ans[ask[i].second]);
            }
        }
    }

    answer(ans);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:17:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |                 if ((i + (1 << k) >> (t + 1)) != (i >> (t + 1))) continue;
      |                      ~~^~~~~~~~~~
swaps.cpp:22:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for (int i = 0; i < res.size(); ++ i){
      |                             ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 3 ms 448 KB Correct
5 Correct 4 ms 344 KB Correct
6 Correct 4 ms 444 KB Correct
7 Correct 3 ms 444 KB Correct
8 Correct 2 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 3 ms 344 KB Correct
5 Correct 4 ms 448 KB Correct
6 Correct 2 ms 340 KB Correct
7 Correct 2 ms 344 KB Correct
8 Correct 4 ms 344 KB Correct
9 Correct 4 ms 680 KB Correct
10 Correct 4 ms 344 KB Correct
11 Correct 2 ms 344 KB Correct
12 Correct 2 ms 444 KB Correct
13 Correct 3 ms 448 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 2 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 2 ms 600 KB Correct
4 Correct 3 ms 448 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 2 ms 600 KB Correct
4 Correct 3 ms 448 KB Correct
5 Correct 1 ms 344 KB Correct
6 Correct 1 ms 436 KB Correct
7 Correct 2 ms 344 KB Correct
8 Correct 2 ms 452 KB Correct
9 Correct 3 ms 584 KB Correct
10 Correct 4 ms 344 KB Correct
11 Correct 2 ms 344 KB Correct
12 Correct 2 ms 580 KB Correct
13 Correct 1 ms 344 KB Correct
14 Correct 1 ms 344 KB Correct
15 Correct 2 ms 344 KB Correct
16 Correct 2 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 2 ms 600 KB Correct
4 Correct 2 ms 344 KB Correct
5 Correct 2 ms 444 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 2 ms 600 KB Correct
4 Correct 2 ms 344 KB Correct
5 Correct 2 ms 444 KB Correct
6 Correct 1 ms 344 KB Correct
7 Correct 1 ms 344 KB Correct
8 Correct 3 ms 344 KB Correct
9 Correct 3 ms 444 KB Correct
10 Correct 2 ms 344 KB Correct
11 Correct 4 ms 344 KB Correct
12 Correct 2 ms 344 KB Correct
13 Correct 2 ms 444 KB Correct
14 Correct 2 ms 448 KB Correct
15 Correct 4 ms 344 KB Correct
16 Correct 4 ms 448 KB Correct
17 Correct 2 ms 344 KB Correct
18 Correct 2 ms 452 KB Correct
19 Correct 1 ms 344 KB Correct
20 Correct 1 ms 344 KB Correct
21 Correct 1 ms 344 KB Correct
22 Correct 2 ms 444 KB Correct
23 Correct 2 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 3 ms 344 KB Correct
5 Correct 2 ms 456 KB Correct
6 Correct 4 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 3 ms 344 KB Correct
5 Correct 2 ms 456 KB Correct
6 Correct 4 ms 344 KB Correct
7 Correct 1 ms 344 KB Correct
8 Correct 1 ms 344 KB Correct
9 Correct 1 ms 344 KB Correct
10 Correct 3 ms 448 KB Correct
11 Correct 2 ms 448 KB Correct
12 Correct 3 ms 444 KB Correct
13 Correct 3 ms 452 KB Correct
14 Correct 2 ms 344 KB Correct
15 Correct 2 ms 456 KB Correct
16 Correct 3 ms 344 KB Correct
17 Correct 2 ms 572 KB Correct
18 Correct 2 ms 344 KB Correct
19 Correct 2 ms 344 KB Correct
20 Correct 1 ms 344 KB Correct
21 Correct 1 ms 344 KB Correct
22 Correct 1 ms 344 KB Correct
23 Correct 2 ms 344 KB Correct
24 Correct 4 ms 344 KB Correct
25 Correct 3 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 1 ms 348 KB Correct
4 Correct 3 ms 344 KB Correct
5 Correct 2 ms 580 KB Correct
6 Correct 2 ms 404 KB Correct
7 Correct 2 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 1 ms 348 KB Correct
4 Correct 3 ms 344 KB Correct
5 Correct 2 ms 580 KB Correct
6 Correct 2 ms 404 KB Correct
7 Correct 2 ms 344 KB Correct
8 Correct 1 ms 344 KB Correct
9 Correct 0 ms 344 KB Correct
10 Correct 1 ms 344 KB Correct
11 Correct 2 ms 436 KB Correct
12 Correct 2 ms 344 KB Correct
13 Correct 2 ms 344 KB Correct
14 Correct 2 ms 440 KB Correct
15 Correct 2 ms 344 KB Correct
16 Correct 3 ms 456 KB Correct
17 Correct 2 ms 448 KB Correct
18 Correct 2 ms 344 KB Correct
19 Correct 2 ms 448 KB Correct
20 Correct 3 ms 700 KB Correct
21 Correct 2 ms 344 KB Correct
22 Correct 0 ms 344 KB Correct
23 Correct 1 ms 344 KB Correct
24 Correct 1 ms 344 KB Correct
25 Correct 2 ms 452 KB Correct
26 Correct 2 ms 344 KB Correct
27 Correct 2 ms 344 KB Correct
28 Correct 4 ms 1572 KB Correct