#include "bits/stdc++.h"
#include "swaps.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
void solve(int N, int V){
vector<vector<int>> v;
for(int i=1;i<=N;i++) v.push_back({i});
while(sz(v)>1){
vector<int> tek={-1};
if(sz(v)&1){
tek=v.back();
v.pop_back();
}
int u=sz(v)/2;
vector<vector<int>> new_shits;
new_shits.resize(u);
while(true){
bool ok=1;
for(int i=0;i<sz(v);i++) if(sz(v[i])) ok=0;
if(ok) break;
vector<int> query;
for(int i=0;i<u;i++){
int a=2*i,b=2*i+1;
if(v[a].empty() && v[b].empty()) continue;
if(v[a].empty()){
new_shits[i].push_back(v[b].back());
v[b].pop_back();
}
else if(v[b].empty()){
new_shits[i].push_back(v[a].back());
v[a].pop_back();
}
else{
query.push_back(i);
schedule(v[a].back(),v[b].back());
}
}
vector<int> res = visit();
for(int i=0;i<sz(res);i++){
int lol = query[i];
if(res[i]){
new_shits[lol].push_back(v[2*lol].back());
v[2*lol].pop_back();
}
else{
new_shits[lol].push_back(v[2*lol+1].back());
v[2*lol+1].pop_back();
}
}
}
for(int i=0;i<u;i++) reverse(all(new_shits[i]));
if(tek[0]!=-1) new_shits.push_back(tek);
tek.clear();
swap(v,new_shits);
new_shits.clear();
}
reverse(all(v[0]));
answer(v[0]);
}
/*void _(){
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
int tc=1;//cin >> tc;
while(tc--) _();
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct |
2 |
Correct |
3 ms |
336 KB |
Correct |
3 |
Correct |
5 ms |
336 KB |
Correct |
4 |
Correct |
7 ms |
336 KB |
Correct |
5 |
Correct |
7 ms |
336 KB |
Correct |
6 |
Correct |
7 ms |
336 KB |
Correct |
7 |
Correct |
8 ms |
504 KB |
Correct |
8 |
Correct |
8 ms |
336 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct |
2 |
Correct |
2 ms |
336 KB |
Correct |
3 |
Correct |
4 ms |
336 KB |
Correct |
4 |
Correct |
9 ms |
336 KB |
Correct |
5 |
Correct |
7 ms |
336 KB |
Correct |
6 |
Correct |
8 ms |
336 KB |
Correct |
7 |
Correct |
7 ms |
336 KB |
Correct |
8 |
Correct |
9 ms |
336 KB |
Correct |
9 |
Runtime error |
7 ms |
336 KB |
Execution killed with signal 13 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Not correct |
2 |
Halted |
0 ms |
0 KB |
- |