답안 #426266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426266 2021-06-13T16:20:05 Z duality The Collection Game (BOI21_swaps) C++14
50 / 100
74 ms 496 KB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int LLI;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
#include "swaps.h"

int used[500];
void solve(int N,int V) {
    int i,j;
    vi order;
    for (i = 0; i < N; i++) order.pb(i+1);
    int s = sqrt(N);
    for (j = 0; j < N/2; j++) {
        vi v1,v2;
        /*for (i = s; i < N; i++) {
            if (!used[i-s]) v1.pb(i),schedule(order[i-s],order[i]),used[i-s] = used[i] = 1;
            else v2.pb(i);
        }
        fill(used,used+N,0);
        vi r = visit();
        for (i = 0; i < r.size(); i++) {
            if (!r[i]) swap(order[v1[i]-s],order[v1[i]]);
        }
        for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-s],order[v2[i]]);
        r = visit();
        for (i = 0; i < r.size(); i++) {
            if (!r[i]) swap(order[v2[i]-s],order[v2[i]]);
        }*/
        v1.clear(),v2.clear();
        for (i = 1; i < N; i++) {
            if (i & 1) schedule(order[i-1],order[i]),v1.pb(i);
            else v2.pb(i);
        }
        vi r = visit();
        for (i = 0; i < r.size(); i++) {
            if (!r[i]) swap(order[v1[i]-1],order[v1[i]]);
        }
        for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-1],order[v2[i]]);
        r = visit();
        for (i = 0; i < r.size(); i++) {
            if (!r[i]) swap(order[v2[i]-1],order[v2[i]]);
        }
    }
    answer(order);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (i = 0; i < r.size(); i++) {
      |                     ~~^~~~~~~~~~
swaps.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (i = 0; i < v2.size(); i++) schedule(order[v2[i]-1],order[v2[i]]);
      |                     ~~^~~~~~~~~~~
swaps.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         for (i = 0; i < r.size(); i++) {
      |                     ~~^~~~~~~~~~
swaps.cpp:16:9: warning: unused variable 's' [-Wunused-variable]
   16 |     int s = sqrt(N);
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 20 ms 200 KB Correct
4 Correct 57 ms 304 KB Correct
5 Correct 56 ms 308 KB Correct
6 Correct 56 ms 300 KB Correct
7 Correct 59 ms 396 KB Correct
8 Correct 54 ms 304 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 5 ms 200 KB Correct
3 Correct 17 ms 200 KB Correct
4 Correct 70 ms 376 KB Correct
5 Correct 56 ms 300 KB Correct
6 Correct 57 ms 308 KB Correct
7 Correct 57 ms 308 KB Correct
8 Correct 64 ms 304 KB Correct
9 Correct 51 ms 304 KB Correct
10 Correct 54 ms 368 KB Correct
11 Correct 68 ms 304 KB Correct
12 Correct 57 ms 408 KB Correct
13 Correct 54 ms 496 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 5 ms 200 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 5 ms 200 KB Correct
3 Correct 1 ms 200 KB Correct
4 Correct 4 ms 200 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 56 ms 304 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 56 ms 304 KB Correct
5 Correct 1 ms 200 KB Correct
6 Correct 4 ms 200 KB Correct
7 Correct 16 ms 200 KB Correct
8 Correct 58 ms 300 KB Correct
9 Correct 69 ms 300 KB Correct
10 Correct 55 ms 332 KB Correct
11 Correct 74 ms 308 KB Correct
12 Correct 55 ms 308 KB Correct
13 Correct 1 ms 200 KB Correct
14 Correct 5 ms 296 KB Correct
15 Correct 20 ms 200 KB Correct
16 Correct 58 ms 304 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 67 ms 304 KB Correct
5 Correct 55 ms 304 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 67 ms 304 KB Correct
5 Correct 55 ms 304 KB Correct
6 Correct 1 ms 200 KB Correct
7 Correct 4 ms 200 KB Correct
8 Correct 16 ms 200 KB Correct
9 Correct 57 ms 300 KB Correct
10 Correct 57 ms 308 KB Correct
11 Correct 67 ms 428 KB Correct
12 Correct 50 ms 296 KB Correct
13 Correct 55 ms 400 KB Correct
14 Correct 62 ms 420 KB Correct
15 Correct 54 ms 304 KB Correct
16 Correct 52 ms 304 KB Correct
17 Correct 68 ms 340 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 16 ms 200 KB Correct
22 Correct 56 ms 304 KB Correct
23 Correct 58 ms 292 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 22 ms 200 KB Correct
4 Correct 69 ms 304 KB Correct
5 Correct 57 ms 284 KB Correct
6 Runtime error 12 ms 284 KB Execution killed with signal 13
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 4 ms 200 KB Correct
3 Correct 22 ms 200 KB Correct
4 Correct 69 ms 304 KB Correct
5 Correct 57 ms 284 KB Correct
6 Runtime error 12 ms 284 KB Execution killed with signal 13
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 5 ms 200 KB Correct
3 Correct 19 ms 200 KB Correct
4 Correct 60 ms 392 KB Correct
5 Correct 62 ms 400 KB Correct
6 Runtime error 13 ms 284 KB Execution killed with signal 13
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 5 ms 200 KB Correct
3 Correct 19 ms 200 KB Correct
4 Correct 60 ms 392 KB Correct
5 Correct 62 ms 400 KB Correct
6 Runtime error 13 ms 284 KB Execution killed with signal 13
7 Halted 0 ms 0 KB -