#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;
for(int i = 0; i < N; i++){
for(int j = i + 1; j < N; j++){
swap(a[i], a[j]);
int new_qry = query(a);
if(new_qry == N) return;
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
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 8 |
2 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 4 |
3 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 14 |
4 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 17 |
5 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 20 |
6 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 15 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 8 |
2 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 4 |
3 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 14 |
4 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 17 |
5 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 20 |
6 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 15 |
7 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1200 |
8 |
Correct |
16 ms |
208 KB |
Correct! Number of queries: 1200 |
9 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1000 |
10 |
Correct |
18 ms |
208 KB |
Correct! Number of queries: 1200 |
11 |
Correct |
9 ms |
208 KB |
Correct! Number of queries: 900 |
12 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1200 |
13 |
Correct |
7 ms |
208 KB |
Correct! Number of queries: 1100 |
14 |
Incorrect |
17 ms |
208 KB |
Unexpected end of file - int32 expected |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 8 |
2 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 4 |
3 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 14 |
4 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 17 |
5 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 20 |
6 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 15 |
7 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1200 |
8 |
Correct |
16 ms |
208 KB |
Correct! Number of queries: 1200 |
9 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1000 |
10 |
Correct |
18 ms |
208 KB |
Correct! Number of queries: 1200 |
11 |
Correct |
9 ms |
208 KB |
Correct! Number of queries: 900 |
12 |
Correct |
13 ms |
208 KB |
Correct! Number of queries: 1200 |
13 |
Correct |
7 ms |
208 KB |
Correct! Number of queries: 1100 |
14 |
Incorrect |
17 ms |
208 KB |
Unexpected end of file - int32 expected |
15 |
Halted |
0 ms |
0 KB |
- |