Submission #581276

# Submission time Handle Problem Language Result Execution time Memory
581276 2022-06-22T12:43:33 Z alontanay The Collection Game (BOI21_swaps) C++14
5 / 100
53 ms 328 KB
//
// --- Sample implementation for the task swaps ---
//
// To compile this program with the sample grader, place:
//     swaps.h swaps_sample.cpp sample_grader.cpp
// in a single folder and run:
//     g++ swaps_sample.cpp sample_grader.cpp
// in this folder.
//
#include "swaps.h"
#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;
using pi = pair<int,int>;

vector<pi> ss;

vector<int> lc;

void _schedule(int i, int j) {
    ss.push_back({i,j});
    schedule(lc[i],lc[j]);
}

void _visit() {
    vector<int> res = visit();
    for(int i = 0; i < res.size(); i ++) {
        if(!res[i]) {
            swap(lc[ss[i].f],lc[ss[i].s]);
        }
    }
    ss.clear();
}

void solve(int N, int V) {
    lc.resize(N+1);
    for(int i = 1; i <= N; i ++) {
        lc[i] = i;
    }
    for(int i = 1; i <= N; i ++) {
        for(int j = i + 1; j <= N; j ++) {
            _schedule(i,j);
            _visit();
        }
    }
    vector<int> res(N);
    for(int i = 0; i < N; i ++) {
        res[i] = lc[i+1];
    }
    answer(res);
}

/*
g++ swaps_.cpp grader.cpp -o g.exe && g.exe
5 1000
2 1 5 3 4
1
1
*/

/*
4 1 5 3 4

*/

Compilation message

swaps.cpp: In function 'void _visit()':
swaps.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 0; i < res.size(); i ++) {
      |                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 39 ms 208 KB Correct
3 Runtime error 49 ms 284 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 45 ms 208 KB Correct
3 Runtime error 51 ms 296 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 53 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 53 ms 208 KB Correct
3 Correct 1 ms 208 KB Correct
4 Correct 44 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 46 ms 208 KB Correct
3 Runtime error 24 ms 276 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 46 ms 208 KB Correct
3 Runtime error 24 ms 276 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 41 ms 208 KB Correct
3 Runtime error 45 ms 328 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 41 ms 208 KB Correct
3 Runtime error 45 ms 328 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 40 ms 208 KB Correct
3 Runtime error 46 ms 280 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 40 ms 208 KB Correct
3 Runtime error 46 ms 280 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 46 ms 208 KB Correct
3 Runtime error 45 ms 280 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 46 ms 208 KB Correct
3 Runtime error 45 ms 280 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -