답안 #402944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402944 2021-05-12T15:07:31 Z doowey The Collection Game (BOI21_swaps) C++14
100 / 100
7 ms 472 KB
#include <bits/stdc++.h>
#include "swaps.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

vector<int> ord;

void do_shit(vector<pii> shit){
    for(auto x : shit){
        schedule(ord[x.fi], ord[x.se]);
    }
    vector<int> gg = visit();
    for(int i = 0 ; i < gg.size(); i ++ ){
        if(!gg[i]){
            swap(ord[shit[i].fi], ord[shit[i].se]);
        }
    }
}

void solve(int n, int q) {
    int nx;
    for(int i = 1; i <= n; i ++ ){
        ord.push_back(i);
    }
    for(int k = 1; k < n * 2; k *= 2){
        vector<pii> ash;
        for(int i = 0 ; i < n; i ++ ){
            nx = (i ^ (k - 1));
            if(i < nx && nx < n)
                ash.push_back(mp(i, nx));
        }
        do_shit(ash);

        for(int v = k / 4; v > 0 ; v /= 2){
            ash.clear();
            for(int j = 0 ; j < n; j ++){
                nx = (j ^ v);
                if(j < nx && nx < n){
                    ash.push_back(mp(j, nx));
                }
            }
            do_shit(ash);
        }
    }
    answer(ord);
}

Compilation message

swaps.cpp: In function 'void do_shit(std::vector<std::pair<int, int> >)':
swaps.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i = 0 ; i < gg.size(); i ++ ){
      |                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 4 ms 200 KB Correct
4 Correct 6 ms 296 KB Correct
5 Correct 7 ms 300 KB Correct
6 Correct 6 ms 304 KB Correct
7 Correct 6 ms 304 KB Correct
8 Correct 5 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 4 ms 200 KB Correct
4 Correct 5 ms 304 KB Correct
5 Correct 5 ms 300 KB Correct
6 Correct 6 ms 300 KB Correct
7 Correct 5 ms 300 KB Correct
8 Correct 5 ms 304 KB Correct
9 Correct 6 ms 304 KB Correct
10 Correct 6 ms 308 KB Correct
11 Correct 6 ms 300 KB Correct
12 Correct 6 ms 304 KB Correct
13 Correct 6 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 1 ms 200 KB Correct
3 Correct 1 ms 200 KB Correct
4 Correct 2 ms 200 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 6 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 6 ms 300 KB Correct
5 Correct 1 ms 200 KB Correct
6 Correct 2 ms 200 KB Correct
7 Correct 3 ms 200 KB Correct
8 Correct 5 ms 296 KB Correct
9 Correct 6 ms 304 KB Correct
10 Correct 6 ms 300 KB Correct
11 Correct 6 ms 412 KB Correct
12 Correct 5 ms 308 KB Correct
13 Correct 1 ms 200 KB Correct
14 Correct 2 ms 200 KB Correct
15 Correct 3 ms 296 KB Correct
16 Correct 6 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 6 ms 304 KB Correct
5 Correct 5 ms 288 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 6 ms 304 KB Correct
5 Correct 5 ms 288 KB Correct
6 Correct 1 ms 200 KB Correct
7 Correct 2 ms 200 KB Correct
8 Correct 3 ms 200 KB Correct
9 Correct 6 ms 304 KB Correct
10 Correct 5 ms 304 KB Correct
11 Correct 5 ms 300 KB Correct
12 Correct 5 ms 304 KB Correct
13 Correct 6 ms 304 KB Correct
14 Correct 6 ms 312 KB Correct
15 Correct 5 ms 300 KB Correct
16 Correct 7 ms 300 KB Correct
17 Correct 6 ms 296 KB Correct
18 Correct 6 ms 304 KB Correct
19 Correct 1 ms 200 KB Correct
20 Correct 1 ms 200 KB Correct
21 Correct 3 ms 296 KB Correct
22 Correct 6 ms 300 KB Correct
23 Correct 6 ms 288 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 296 KB Correct
4 Correct 6 ms 300 KB Correct
5 Correct 5 ms 284 KB Correct
6 Correct 7 ms 288 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 296 KB Correct
4 Correct 6 ms 300 KB Correct
5 Correct 5 ms 284 KB Correct
6 Correct 7 ms 288 KB Correct
7 Correct 1 ms 200 KB Correct
8 Correct 2 ms 200 KB Correct
9 Correct 3 ms 200 KB Correct
10 Correct 6 ms 304 KB Correct
11 Correct 6 ms 304 KB Correct
12 Correct 6 ms 300 KB Correct
13 Correct 6 ms 308 KB Correct
14 Correct 6 ms 304 KB Correct
15 Correct 5 ms 304 KB Correct
16 Correct 6 ms 312 KB Correct
17 Correct 5 ms 304 KB Correct
18 Correct 6 ms 300 KB Correct
19 Correct 6 ms 304 KB Correct
20 Correct 1 ms 200 KB Correct
21 Correct 2 ms 200 KB Correct
22 Correct 3 ms 200 KB Correct
23 Correct 7 ms 304 KB Correct
24 Correct 7 ms 284 KB Correct
25 Correct 6 ms 284 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 5 ms 300 KB Correct
5 Correct 5 ms 296 KB Correct
6 Correct 7 ms 284 KB Correct
7 Correct 5 ms 284 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 2 ms 200 KB Correct
3 Correct 3 ms 200 KB Correct
4 Correct 5 ms 300 KB Correct
5 Correct 5 ms 296 KB Correct
6 Correct 7 ms 284 KB Correct
7 Correct 5 ms 284 KB Correct
8 Correct 1 ms 200 KB Correct
9 Correct 1 ms 200 KB Correct
10 Correct 2 ms 200 KB Correct
11 Correct 3 ms 296 KB Correct
12 Correct 6 ms 300 KB Correct
13 Correct 6 ms 304 KB Correct
14 Correct 6 ms 472 KB Correct
15 Correct 5 ms 300 KB Correct
16 Correct 6 ms 308 KB Correct
17 Correct 6 ms 308 KB Correct
18 Correct 6 ms 304 KB Correct
19 Correct 5 ms 300 KB Correct
20 Correct 5 ms 320 KB Correct
21 Correct 6 ms 304 KB Correct
22 Correct 1 ms 200 KB Correct
23 Correct 1 ms 200 KB Correct
24 Correct 3 ms 200 KB Correct
25 Correct 6 ms 308 KB Correct
26 Correct 6 ms 280 KB Correct
27 Correct 6 ms 288 KB Correct
28 Correct 6 ms 292 KB Correct