답안 #406785

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406785 2021-05-18T05:01:19 Z KleindianaLexington Mouse (info1cup19_mouse) C++17
40.6667 / 100
193 ms 256 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;

bool ok[300];

void solve(int N) {
	memset(ok, false, sizeof(ok));
	vector<int> q;
	for(int i = 1; i <= N; i++) {
		q.push_back(i);
	}
	random_shuffle (q.begin(), q.end());
	for(int i = 0; i < N; i++) {
		if(ok[i]) {
			continue;
		}
		int val = -1;
		int idx1 = -1;
		int idx2 = -1;
		for(int j = i; j < N; j++) {
			if(ok[j]) {
				continue;
			}
			swap(q[i], q[j]);
			int ret = query(q);
			if(ret == N) {
				return;
			}
			if(ret > val) {
				val = ret;
				idx1 = j;
				idx2 = -1;
			}
			else if(ret == val) {
				idx2 = j;
			}
			swap(q[i], q[j]);
		}
		if(idx2 == -1) {
			swap(q[i], q[idx1]);
			ok[i] = true;
			ok[idx1] = true;
		}
		else {
			swap(q[i], q[idx1]);
			swap(q[idx1], q[idx2]);
			int ret = query(q);
			if(ret == N) {
				return;
			}
			if(ret > val) {
				ok[i] = true;
				ok[idx2] = true;
			}
			else {
				swap(q[idx1], q[idx2]);
				swap(q[i], q[idx2]);
				ok[i] = true;
				ok[idx1] = true;
			}
		}
	}
	query(q);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct! Number of queries: 20
2 Correct 1 ms 200 KB Correct! Number of queries: 4
3 Correct 1 ms 200 KB Correct! Number of queries: 13
4 Correct 1 ms 200 KB Correct! Number of queries: 22
5 Correct 1 ms 200 KB Correct! Number of queries: 19
6 Correct 1 ms 200 KB Correct! Number of queries: 16
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct! Number of queries: 20
2 Correct 1 ms 200 KB Correct! Number of queries: 4
3 Correct 1 ms 200 KB Correct! Number of queries: 13
4 Correct 1 ms 200 KB Correct! Number of queries: 22
5 Correct 1 ms 200 KB Correct! Number of queries: 19
6 Correct 1 ms 200 KB Correct! Number of queries: 16
7 Correct 11 ms 200 KB Correct! Number of queries: 700
8 Correct 13 ms 200 KB Correct! Number of queries: 700
9 Correct 10 ms 200 KB Correct! Number of queries: 600
10 Correct 13 ms 200 KB Correct! Number of queries: 800
11 Correct 7 ms 200 KB Correct! Number of queries: 500
12 Correct 12 ms 200 KB Correct! Number of queries: 700
13 Correct 10 ms 200 KB Correct! Number of queries: 600
14 Correct 13 ms 256 KB Correct! Number of queries: 700
15 Correct 10 ms 200 KB Correct! Number of queries: 700
16 Correct 10 ms 200 KB Correct! Number of queries: 700
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Correct! Number of queries: 20
2 Correct 1 ms 200 KB Correct! Number of queries: 4
3 Correct 1 ms 200 KB Correct! Number of queries: 13
4 Correct 1 ms 200 KB Correct! Number of queries: 22
5 Correct 1 ms 200 KB Correct! Number of queries: 19
6 Correct 1 ms 200 KB Correct! Number of queries: 16
7 Correct 11 ms 200 KB Correct! Number of queries: 700
8 Correct 13 ms 200 KB Correct! Number of queries: 700
9 Correct 10 ms 200 KB Correct! Number of queries: 600
10 Correct 13 ms 200 KB Correct! Number of queries: 800
11 Correct 7 ms 200 KB Correct! Number of queries: 500
12 Correct 12 ms 200 KB Correct! Number of queries: 700
13 Correct 10 ms 200 KB Correct! Number of queries: 600
14 Correct 13 ms 256 KB Correct! Number of queries: 700
15 Correct 10 ms 200 KB Correct! Number of queries: 700
16 Correct 10 ms 200 KB Correct! Number of queries: 700
17 Runtime error 193 ms 200 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -