답안 #417890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417890 2021-06-04T13:09:37 Z Kevin_Zhang_TW The Collection Game (BOI21_swaps) C++17
35 / 100
131 ms 492 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
#include "swaps.h"

const int MAX_N = 300010;

void solve(int N, int V) {

	vector<int> id(N); iota(AI(id), 1);


	{
		vector<pair<int,int>> comp;

		int mid = (N+1) / 2;
		for (int i = mid;i < N;++i)
			comp.pb(i-mid, i);

		vector<int> ret = visit();
		for (int j = 0;j < ret.size();++j) {
			if (ret[j] == 0) {
				auto [x, y] = comp[j];
				swap(id[x], id[y]);
			}
		}
	}

	chmin(V, 2 * N);

	for (int i = 1;i < V;++i) {
		vector<pair<int,int>> comp;
		for (int j = ~i&1;j+1 < N;j += 2) { 
			schedule(id[j], id[j+1]);
			comp.pb(j, j+1);
		}
		vector<int> ret = visit();
		for (int j = 0;j < ret.size();++j) {
			if (ret[j] == 0) {
				auto [x, y] = comp[j];
				swap(id[x], id[y]);
			}
		}
	}

	answer(id);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for (int j = 0;j < ret.size();++j) {
      |                  ~~^~~~~~~~~~~~
swaps.cpp:51:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   for (int j = 0;j < ret.size();++j) {
      |                  ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 8 ms 200 KB Correct
3 Correct 33 ms 200 KB Correct
4 Correct 102 ms 296 KB Correct
5 Correct 107 ms 492 KB Correct
6 Correct 101 ms 296 KB Correct
7 Correct 121 ms 380 KB Correct
8 Correct 104 ms 340 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 8 ms 288 KB Correct
3 Correct 36 ms 200 KB Correct
4 Correct 118 ms 444 KB Correct
5 Correct 126 ms 360 KB Correct
6 Correct 103 ms 492 KB Correct
7 Correct 131 ms 296 KB Correct
8 Correct 119 ms 432 KB Correct
9 Correct 103 ms 304 KB Correct
10 Correct 107 ms 368 KB Correct
11 Correct 124 ms 296 KB Correct
12 Correct 112 ms 408 KB Correct
13 Correct 103 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 6 ms 200 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 6 ms 200 KB Correct
3 Correct 1 ms 200 KB Correct
4 Correct 7 ms 268 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 6 ms 200 KB Correct
3 Correct 31 ms 200 KB Correct
4 Correct 113 ms 408 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 6 ms 200 KB Correct
3 Correct 31 ms 200 KB Correct
4 Correct 113 ms 408 KB Correct
5 Correct 1 ms 200 KB Correct
6 Correct 6 ms 200 KB Correct
7 Correct 28 ms 200 KB Correct
8 Correct 105 ms 372 KB Correct
9 Correct 107 ms 312 KB Correct
10 Correct 103 ms 404 KB Correct
11 Correct 107 ms 396 KB Correct
12 Correct 112 ms 304 KB Correct
13 Correct 1 ms 200 KB Correct
14 Correct 6 ms 200 KB Correct
15 Correct 34 ms 200 KB Correct
16 Correct 117 ms 300 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 6 ms 200 KB Correct
3 Correct 30 ms 200 KB Correct
4 Correct 122 ms 300 KB Correct
5 Incorrect 58 ms 300 KB Not correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 6 ms 200 KB Correct
3 Correct 30 ms 200 KB Correct
4 Correct 122 ms 300 KB Correct
5 Incorrect 58 ms 300 KB Not correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 6 ms 200 KB Correct
3 Correct 33 ms 200 KB Correct
4 Correct 113 ms 300 KB Correct
5 Incorrect 50 ms 300 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 6 ms 200 KB Correct
3 Correct 33 ms 200 KB Correct
4 Correct 113 ms 300 KB Correct
5 Incorrect 50 ms 300 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 8 ms 200 KB Correct
3 Correct 29 ms 200 KB Correct
4 Correct 116 ms 424 KB Correct
5 Incorrect 54 ms 300 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct
2 Correct 8 ms 200 KB Correct
3 Correct 29 ms 200 KB Correct
4 Correct 116 ms 424 KB Correct
5 Incorrect 54 ms 300 KB Not correct
6 Halted 0 ms 0 KB -