제출 #674443

#제출 시각아이디문제언어결과실행 시간메모리
674443QwertyPiMouse (info1cup19_mouse)C++14
21.60 / 100
148 ms284 KiB
#include <bits/stdc++.h>
using namespace std;

#ifndef TEST
#include "grader.h"
int query(vector<int> q);
#else
vector<int> p;

int qc = 0;
int query(vector<int> q){
	qc++;
	int cnt = 0;
	int n = p.size();
	for(int i = 0; i < n; i++){
		if(p[i] == q[i]) cnt++;
	}
	return cnt;
}
#endif

void solve(int N){
	vector<int> a;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	for(int i = 1; i <= N; i++){
		a.push_back(i);
	}
	for(int i = 0; i < N; i++){
		swap(a[i], a[rng() % (i + 1)]);
	}
	int qry = 0;
	while(qry != N){
		int i = 0, j = 0;
		while(i == j) i = rng() % N, j = rng() % N;
		swap(a[i], a[j]);
		int new_qry = query(a);
		if(new_qry < qry) swap(a[i], a[j]);
		else qry = new_qry;
	}
}

#ifdef TEST
int main(){
	int N; cin >> N; p.resize(N);
	for(int i = 0; i < N; i++) cin >> p[i];
	solve(N);
	cout << qc << endl;
}
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...