#include "grid.h"
#include <algorithm>
#include <iostream>
using namespace std;
int n;
vector<int> tmp, lis;
bool cmp(int i, int j){
bool used[1010]={};
for(int x:lis) used[x]=true, tmp.push_back(x);
used[i] = used[j] = true;
for(int k=0; k<n; k++) if(!used[k]) tmp.push_back(k);
tmp.push_back(j);
tmp.push_back(i);
reverse(tmp.begin(), tmp.end());
int x = PutDisks(tmp);
swap(tmp[0], tmp[1]);
int y = PutDisks(tmp);
tmp.clear();
return x<y;
}
std::vector<int> SortDisks(int N) {
n=N;
vector<int> ans;
for(int i=0; i<n; i++) ans.push_back(-1);
for(int i=n; i>=1; i--){
int x = -1;
for(int j=0; j<n; j++){
if(ans[j]>=0) continue;
if(x<0){ x=j; continue; }
if(cmp(x,j)) x=j;
}
ans[x] = i, lis.push_back(x);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Incorrect |
12 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Incorrect |
12 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Incorrect |
12 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |