Submission #726880

# Submission time Handle Problem Language Result Execution time Memory
726880 2023-04-19T13:38:13 Z gagik_2007 The Collection Game (BOI21_swaps) C++17
50 / 100
61 ms 448 KB
#include "swaps.h"
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <chrono>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <random>
#include <cassert>
using namespace std;

typedef long long ll;
typedef long double ld;

#define ff first
#define ss second

ll ttt;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll N = 200007;
ll n, m;
int val[N];

void solve(int NN, int VV) {
	vector<int>p;
	n = NN;
	if (n == 1) {
		answer({ 1 });
		return;
	}
	for (int i = 1; i <= n; i++) {
		val[i] = i;
	}
	int cl = 1;
	for (int c = 0; c < n; c++) {
		int l = cl;
		vector<pair<int, int>>s;
		while (l + 1 <= n) {
			schedule(val[l], val[l + 1]);
			s.push_back({ l,l + 1 });
			l += 2;
		}
		vector<int>d = visit();
		for (int i = 0; i < s.size(); i++) {
			if (d[i] == 0) {
				swap(val[s[i].ff], val[s[i].ss]);
			}
		}
		if (cl == 2) {
			cl = 1;
		}
		else {
			cl = 2;
		}
	}
	for (int i = 1; i <= n; i++) {
		p.push_back(val[i]);
	}
	answer(p);
}

Compilation message

swaps.cpp: In function 'void solve(int, int)':
swaps.cpp:57:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   for (int i = 0; i < s.size(); i++) {
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 4 ms 208 KB Correct
3 Correct 13 ms 208 KB Correct
4 Correct 48 ms 396 KB Correct
5 Correct 43 ms 324 KB Correct
6 Correct 40 ms 316 KB Correct
7 Correct 44 ms 316 KB Correct
8 Correct 39 ms 316 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 15 ms 208 KB Correct
4 Correct 51 ms 412 KB Correct
5 Correct 43 ms 316 KB Correct
6 Correct 48 ms 312 KB Correct
7 Correct 56 ms 312 KB Correct
8 Correct 50 ms 368 KB Correct
9 Correct 46 ms 316 KB Correct
10 Correct 50 ms 312 KB Correct
11 Correct 42 ms 312 KB Correct
12 Correct 46 ms 312 KB Correct
13 Correct 43 ms 316 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 1 ms 208 KB Correct
4 Correct 3 ms 208 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 12 ms 208 KB Correct
4 Correct 44 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 12 ms 208 KB Correct
4 Correct 44 ms 348 KB Correct
5 Correct 0 ms 208 KB Correct
6 Correct 3 ms 208 KB Correct
7 Correct 12 ms 208 KB Correct
8 Correct 47 ms 380 KB Correct
9 Correct 42 ms 316 KB Correct
10 Correct 53 ms 408 KB Correct
11 Correct 61 ms 320 KB Correct
12 Correct 45 ms 312 KB Correct
13 Correct 0 ms 208 KB Correct
14 Correct 3 ms 208 KB Correct
15 Correct 13 ms 208 KB Correct
16 Correct 45 ms 316 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 12 ms 208 KB Correct
4 Correct 46 ms 308 KB Correct
5 Correct 43 ms 300 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 12 ms 208 KB Correct
4 Correct 46 ms 308 KB Correct
5 Correct 43 ms 300 KB Correct
6 Correct 1 ms 208 KB Correct
7 Correct 4 ms 208 KB Correct
8 Correct 13 ms 208 KB Correct
9 Correct 48 ms 340 KB Correct
10 Correct 49 ms 316 KB Correct
11 Correct 44 ms 316 KB Correct
12 Correct 39 ms 312 KB Correct
13 Correct 61 ms 316 KB Correct
14 Correct 51 ms 316 KB Correct
15 Correct 42 ms 312 KB Correct
16 Correct 48 ms 316 KB Correct
17 Correct 43 ms 316 KB Correct
18 Correct 47 ms 372 KB Correct
19 Correct 1 ms 208 KB Correct
20 Correct 3 ms 208 KB Correct
21 Correct 13 ms 208 KB Correct
22 Correct 48 ms 312 KB Correct
23 Correct 53 ms 320 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 296 KB Correct
3 Correct 13 ms 208 KB Correct
4 Correct 40 ms 316 KB Correct
5 Correct 60 ms 296 KB Correct
6 Runtime error 9 ms 348 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 296 KB Correct
3 Correct 13 ms 208 KB Correct
4 Correct 40 ms 316 KB Correct
5 Correct 60 ms 296 KB Correct
6 Runtime error 9 ms 348 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 12 ms 208 KB Correct
4 Correct 44 ms 316 KB Correct
5 Correct 55 ms 316 KB Correct
6 Runtime error 10 ms 448 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Correct
2 Correct 3 ms 208 KB Correct
3 Correct 12 ms 208 KB Correct
4 Correct 44 ms 316 KB Correct
5 Correct 55 ms 316 KB Correct
6 Runtime error 10 ms 448 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -