답안 #444412

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
444412 2021-07-14T04:24:26 Z blue The Collection Game (BOI21_swaps) C++17
50 / 100
70 ms 496 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)
{
    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 v = 1; v <= min(V, N); v++)
    {
        vector<int> A, B;
        if(v % 2 == 0)
        {
            for(int i = 0; i+1 < N; i += 2)
            {
                A.push_back(i);
                B.push_back(i+1);
            }
        }
        else
        {
            for(int i = 1; i+1 < N; i += 2)
            {
                A.push_back(i);
                B.push_back(i+1);
            }
        }

        do_comparisons(A, B);
    }

    answer(r);
}

Compilation message

swaps.cpp: In function 'void do_comparisons(std::vector<int>, std::vector<int>)':
swaps.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i = 0; i < A.size(); i++)
      |                    ~~^~~~~~~~~~
swaps.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0; i < A.size(); i++)
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 3 ms 200 KB Correct
3 Correct 16 ms 200 KB Correct
4 Correct 56 ms 300 KB Correct
5 Correct 55 ms 392 KB Correct
6 Correct 54 ms 304 KB Correct
7 Correct 55 ms 296 KB Correct
8 Correct 53 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 15 ms 200 KB Correct
4 Correct 55 ms 296 KB Correct
5 Correct 62 ms 312 KB Correct
6 Correct 59 ms 372 KB Correct
7 Correct 66 ms 276 KB Correct
8 Correct 55 ms 296 KB Correct
9 Correct 53 ms 304 KB Correct
10 Correct 56 ms 304 KB Correct
11 Correct 54 ms 304 KB Correct
12 Correct 57 ms 328 KB Correct
13 Correct 55 ms 320 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 0 ms 200 KB Correct
4 Correct 4 ms 200 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 3 ms 200 KB Correct
3 Correct 15 ms 200 KB Correct
4 Correct 59 ms 412 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 3 ms 200 KB Correct
3 Correct 15 ms 200 KB Correct
4 Correct 59 ms 412 KB Correct
5 Correct 1 ms 200 KB Correct
6 Correct 3 ms 200 KB Correct
7 Correct 14 ms 200 KB Correct
8 Correct 56 ms 332 KB Correct
9 Correct 55 ms 340 KB Correct
10 Correct 56 ms 404 KB Correct
11 Correct 55 ms 344 KB Correct
12 Correct 60 ms 300 KB Correct
13 Correct 1 ms 200 KB Correct
14 Correct 4 ms 200 KB Correct
15 Correct 15 ms 200 KB Correct
16 Correct 70 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 21 ms 200 KB Correct
4 Correct 53 ms 376 KB Correct
5 Correct 69 ms 280 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 21 ms 200 KB Correct
4 Correct 53 ms 376 KB Correct
5 Correct 69 ms 280 KB Correct
6 Correct 0 ms 200 KB Correct
7 Correct 5 ms 200 KB Correct
8 Correct 14 ms 200 KB Correct
9 Correct 51 ms 352 KB Correct
10 Correct 56 ms 376 KB Correct
11 Correct 59 ms 300 KB Correct
12 Correct 54 ms 300 KB Correct
13 Correct 56 ms 300 KB Correct
14 Correct 60 ms 396 KB Correct
15 Correct 55 ms 300 KB Correct
16 Correct 60 ms 380 KB Correct
17 Correct 54 ms 376 KB Correct
18 Correct 56 ms 300 KB Correct
19 Correct 1 ms 200 KB Correct
20 Correct 4 ms 200 KB Correct
21 Correct 19 ms 200 KB Correct
22 Correct 55 ms 496 KB Correct
23 Correct 56 ms 280 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 16 ms 200 KB Correct
4 Correct 54 ms 372 KB Correct
5 Correct 55 ms 276 KB Correct
6 Incorrect 14 ms 280 KB Not correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 16 ms 200 KB Correct
4 Correct 54 ms 372 KB Correct
5 Correct 55 ms 276 KB Correct
6 Incorrect 14 ms 280 KB Not correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 18 ms 200 KB Correct
4 Correct 67 ms 300 KB Correct
5 Correct 54 ms 284 KB Correct
6 Incorrect 11 ms 356 KB Not correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 18 ms 200 KB Correct
4 Correct 67 ms 300 KB Correct
5 Correct 54 ms 284 KB Correct
6 Incorrect 11 ms 356 KB Not correct
7 Halted 0 ms 0 KB -