#include "grader.h"
#include<bits/stdc++.h>
using namespace std ;
int n, num ;
vector<int> per, ans ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> indi ;
void del(int x){
for(int i = 0 ;i < (int) indi.size() ; ++ i){
if(indi[i] == x){
indi.erase(indi.begin() + i , indi.begin() + i + 1) ;
return ;
}
}
}
void print(){
for(int i = 0 ;i < n; ++ i)
cout<< ans[i] <<" " ;
cout<<".\n" ;
}
void solve(int n){
for(int i = 1;i <= n ; ++ i){
ans.push_back(i) ;
}
for(int i = 0 ;i < n; ++ i){
indi.push_back(i) ;
}
for(int i = 0 ;i < n; ++ i){
// int x ; cin >> x ;
// per.push_back(x) ;
}
random_shuffle(ans.begin() , ans.end() ) ;
int tim = 0 ;
int las = 0 ;
las = query(ans) ;
while(tim ++ < 1000000){
int sz = (int) indi.size() ;
int x = rng() % sz ;
int y = rng() % sz ;
x = indi[x] ;
y = indi[y] ;
if(x == y)continue ;
swap(ans[x],ans[y]) ;
int now = query(ans) ;
if( abs(now - las) == 2){
del(x) ; del(y) ;
}
if(now < las)swap(ans[x],ans[y]) ;
las = max(las , now) ;
if(now == n)
break ;
}
return ;
if(las == n)
cout<<"ok " ;
else {
for(auto u : ans)cout<< u <<" " ;
cout<<"incorrect " ;
}
return ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 12 |
2 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 5 |
3 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 14 |
4 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 20 |
5 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 34 |
6 |
Correct |
0 ms |
256 KB |
Correct! Number of queries: 11 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 12 |
2 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 5 |
3 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 14 |
4 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 20 |
5 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 34 |
6 |
Correct |
0 ms |
256 KB |
Correct! Number of queries: 11 |
7 |
Correct |
20 ms |
256 KB |
Correct! Number of queries: 1000 |
8 |
Correct |
16 ms |
256 KB |
Correct! Number of queries: 1200 |
9 |
Correct |
8 ms |
256 KB |
Correct! Number of queries: 600 |
10 |
Correct |
12 ms |
256 KB |
Correct! Number of queries: 900 |
11 |
Correct |
9 ms |
256 KB |
Correct! Number of queries: 700 |
12 |
Correct |
11 ms |
256 KB |
Correct! Number of queries: 700 |
13 |
Correct |
11 ms |
256 KB |
Correct! Number of queries: 700 |
14 |
Correct |
12 ms |
256 KB |
Correct! Number of queries: 900 |
15 |
Correct |
13 ms |
256 KB |
Correct! Number of queries: 900 |
16 |
Correct |
10 ms |
256 KB |
Correct! Number of queries: 800 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 12 |
2 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 5 |
3 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 14 |
4 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 20 |
5 |
Correct |
1 ms |
256 KB |
Correct! Number of queries: 34 |
6 |
Correct |
0 ms |
256 KB |
Correct! Number of queries: 11 |
7 |
Correct |
20 ms |
256 KB |
Correct! Number of queries: 1000 |
8 |
Correct |
16 ms |
256 KB |
Correct! Number of queries: 1200 |
9 |
Correct |
8 ms |
256 KB |
Correct! Number of queries: 600 |
10 |
Correct |
12 ms |
256 KB |
Correct! Number of queries: 900 |
11 |
Correct |
9 ms |
256 KB |
Correct! Number of queries: 700 |
12 |
Correct |
11 ms |
256 KB |
Correct! Number of queries: 700 |
13 |
Correct |
11 ms |
256 KB |
Correct! Number of queries: 700 |
14 |
Correct |
12 ms |
256 KB |
Correct! Number of queries: 900 |
15 |
Correct |
13 ms |
256 KB |
Correct! Number of queries: 900 |
16 |
Correct |
10 ms |
256 KB |
Correct! Number of queries: 800 |
17 |
Execution timed out |
3005 ms |
256 KB |
Time limit exceeded |
18 |
Halted |
0 ms |
0 KB |
- |