#include "grid.h"
typedef std::vector<int> VI;
bool visit[1001] = { 0, };
// ģ�� ���� �����
VI makeSeq(int N, int start, VI &found, VI &len_friend) {
VI v(N);
for (int i = N - 1; i >= 0; --i) {
if (len_friend[i])
v[i] = len_friend[i];
break;
}
for (int i = 0, count = 0; count < N; ++count) {
int num = (start + count) % N;
if (visit[num])
continue;
v[i++] = num;
}
return v;
}
VI SortDisks(int N) {
VI found(N, 0);
VI len_friend(N, 0);
int max_h = N + (N - 1);
for (int L = N; L >= 1; --L) {
for (int i = 0; i < N; ++i) {
VI v = makeSeq(N, i, found, len_friend);
int X = PutDisks(v);
if (X != max_h)
continue;
found[v[0]] = L;
visit[v[0]] = true;
len_friend[L - 1] = v[0];
--max_h;
break;
}
}
return found;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
7 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
7 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Incorrect |
7 ms |
256 KB |
Output isn't correct |