답안 #467820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467820 2021-08-24T20:53:39 Z blue The Collection Game (BOI21_swaps) C++17
100 / 100
7 ms 524 KB
#include "swaps.h"
#include <vector>
#include <iostream>
using namespace std;

int N;
int V;

vector<int> r;

void do_comparisons(vector<int> A, vector<int> B)
{
    if(A.size() == 0) return;
    
    for(int i = 0; i < A.size(); i++)
    {
        schedule(r[ A[i] ], r[ B[i] ]);
    }

    vector<int> C = visit();

    for(int i = 0; i < A.size(); i++)
    {
        if(C[i] == 0)
            swap(r[ A[i] ], r[ B[i] ]);
    }
}


void solve(int n, int v)
{
    N = n;
    V = v;
    r = vector<int>(N);
    for(int i = 1; i <= N; i++) r[i - 1] = i;

    for(int p = 1; p < N; p *= 2)
    {
        for(int k = p; k >= 1; k /= 2)
        {
            vector<int> A, B;
            for(int j = k % p; j <= n-1-k; j += 2*k)
            {
                for(int i = 0; i <= k-1; i++)
                {
                    if((i+j)/(2*p) == (i+j+k)/(2*p))
                    {
                        // cerr << i+j << ' ' << i+j+k << '\n';
                        if(i+j+k < N)
                        {
                        A.push_back(i+j);
                        B.push_back(i+j+k);

                        }
                    }
                }
            }
            do_comparisons(A, B);
        }
    }

    answer(r);
}

Compilation message

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