#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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 44 |
2 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 4 |
3 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 17 |
4 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 71 |
5 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 16 |
6 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 28 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 44 |
2 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 4 |
3 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 17 |
4 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 71 |
5 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 16 |
6 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 28 |
7 |
Correct |
70 ms |
208 KB |
Correct! Number of queries: 5600 |
8 |
Correct |
54 ms |
208 KB |
Correct! Number of queries: 4600 |
9 |
Correct |
41 ms |
208 KB |
Correct! Number of queries: 3900 |
10 |
Correct |
39 ms |
208 KB |
Correct! Number of queries: 5300 |
11 |
Correct |
21 ms |
208 KB |
Correct! Number of queries: 2200 |
12 |
Correct |
28 ms |
208 KB |
Correct! Number of queries: 2700 |
13 |
Correct |
49 ms |
208 KB |
Correct! Number of queries: 3900 |
14 |
Correct |
48 ms |
208 KB |
Correct! Number of queries: 3900 |
15 |
Correct |
40 ms |
208 KB |
Correct! Number of queries: 3000 |
16 |
Correct |
33 ms |
208 KB |
Correct! Number of queries: 3000 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 44 |
2 |
Correct |
0 ms |
208 KB |
Correct! Number of queries: 4 |
3 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 17 |
4 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 71 |
5 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 16 |
6 |
Correct |
1 ms |
208 KB |
Correct! Number of queries: 28 |
7 |
Correct |
70 ms |
208 KB |
Correct! Number of queries: 5600 |
8 |
Correct |
54 ms |
208 KB |
Correct! Number of queries: 4600 |
9 |
Correct |
41 ms |
208 KB |
Correct! Number of queries: 3900 |
10 |
Correct |
39 ms |
208 KB |
Correct! Number of queries: 5300 |
11 |
Correct |
21 ms |
208 KB |
Correct! Number of queries: 2200 |
12 |
Correct |
28 ms |
208 KB |
Correct! Number of queries: 2700 |
13 |
Correct |
49 ms |
208 KB |
Correct! Number of queries: 3900 |
14 |
Correct |
48 ms |
208 KB |
Correct! Number of queries: 3900 |
15 |
Correct |
40 ms |
208 KB |
Correct! Number of queries: 3000 |
16 |
Correct |
33 ms |
208 KB |
Correct! Number of queries: 3000 |
17 |
Runtime error |
148 ms |
284 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |