답안 #315223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315223 2020-10-22T04:58:13 Z thtsshz_bgwrswh Mouse (info1cup19_mouse) C++17
29.5058 / 100
3000 ms 256 KB
#pragma GCC optimize("Ofast")
#include "grader.h"
#include<stdio.h>
#include<algorithm>
#include<assert.h>
using namespace std;
int num[500];
bool check[500],wrong[500];
void solve(int n){
	int i,j;
	for(i=0;i<n;i++)
		wrong[i]=check[i]=0;
	vector<int> vec(n);
	for(i=0;i<n;i++)
		vec[i]=i+1;
	random_shuffle(vec.begin(),vec.end());
	int now=query(vec);
	if(now==n)
		return;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			swap(vec[j],vec[i]);
			int v=query(vec);
			if(v==n)
				return;
			if(v==now-2)
				check[i]=check[j]=1;
			else if(v==now)
				wrong[i]=wrong[j]=1;
			swap(vec[i],vec[j]);
		}
	} 
	vector<int> order;
	for(i=0;i<n;i++)
		if(wrong[i])
			order.emplace_back(i);
	for(i=0;i<n;i++)
		check[i]=0;
	for(i=0;i<(int)order.size();i++){
		for(j=i+1;j<(int)order.size();j++){
			if(check[i]||check[j])
				continue;
			swap(vec[order[i]],vec[order[j]]);
			int v=query(vec);
			if(v==n)
				return;
			if(v==now+2){
				now+=2;
				check[i]=check[j]=1;
				break;
			}
			swap(vec[order[i]],vec[order[j]]);
		}
	}
	while(1){
		for(i=0;i<(int)order.size();i++){
			for(j=i+1;j<(int)order.size();j++){
				if(check[i]||check[j])
					continue;
				swap(vec[order[i]],vec[order[j]]);
				int v=query(vec);
				if(v==n)
					return;
				if(v==now+2){
					now+=2;
					check[i]=check[j]=1;
					break;
				}
				else if(v==now+1)
					now++;	
				else
					swap(vec[order[i]],vec[order[j]]);
			}
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Correct! Number of queries: 37
2 Correct 0 ms 256 KB Correct! Number of queries: 4
3 Correct 1 ms 256 KB Correct! Number of queries: 34
4 Correct 1 ms 256 KB Correct! Number of queries: 42
5 Correct 1 ms 256 KB Correct! Number of queries: 42
6 Correct 1 ms 256 KB Correct! Number of queries: 49
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Correct! Number of queries: 37
2 Correct 0 ms 256 KB Correct! Number of queries: 4
3 Correct 1 ms 256 KB Correct! Number of queries: 34
4 Correct 1 ms 256 KB Correct! Number of queries: 42
5 Correct 1 ms 256 KB Correct! Number of queries: 42
6 Correct 1 ms 256 KB Correct! Number of queries: 49
7 Correct 50 ms 256 KB Correct! Number of queries: 3600
8 Correct 52 ms 256 KB Correct! Number of queries: 3600
9 Correct 41 ms 256 KB Correct! Number of queries: 2900
10 Correct 49 ms 256 KB Correct! Number of queries: 3500
11 Correct 29 ms 256 KB Correct! Number of queries: 2300
12 Correct 47 ms 256 KB Correct! Number of queries: 3600
13 Correct 39 ms 256 KB Correct! Number of queries: 2800
14 Correct 56 ms 256 KB Correct! Number of queries: 3600
15 Correct 39 ms 256 KB Correct! Number of queries: 3500
16 Correct 46 ms 256 KB Correct! Number of queries: 3200
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Correct! Number of queries: 37
2 Correct 0 ms 256 KB Correct! Number of queries: 4
3 Correct 1 ms 256 KB Correct! Number of queries: 34
4 Correct 1 ms 256 KB Correct! Number of queries: 42
5 Correct 1 ms 256 KB Correct! Number of queries: 42
6 Correct 1 ms 256 KB Correct! Number of queries: 49
7 Correct 50 ms 256 KB Correct! Number of queries: 3600
8 Correct 52 ms 256 KB Correct! Number of queries: 3600
9 Correct 41 ms 256 KB Correct! Number of queries: 2900
10 Correct 49 ms 256 KB Correct! Number of queries: 3500
11 Correct 29 ms 256 KB Correct! Number of queries: 2300
12 Correct 47 ms 256 KB Correct! Number of queries: 3600
13 Correct 39 ms 256 KB Correct! Number of queries: 2800
14 Correct 56 ms 256 KB Correct! Number of queries: 3600
15 Correct 39 ms 256 KB Correct! Number of queries: 3500
16 Correct 46 ms 256 KB Correct! Number of queries: 3200
17 Execution timed out 3018 ms 256 KB Time limit exceeded
18 Halted 0 ms 0 KB -