Submission #149380

# Submission time Handle Problem Language Result Execution time Memory
149380 2019-09-01T06:21:32 Z USA1(#3634, ecnerwala, scott_wu, ksun48) On the Grid (FXCUP4_grid) C++17
43 / 100
12 ms 384 KB
#include "grid.h"
#include <bits/stdc++.h>

using namespace std;
const int MAXN = 1100;

int N;
vector <int> cv;
vector <int> nv;
int ans[MAXN];

void cyc (int M, int K)
{
    nv.clear();
    for (int i = 0; i < M; i++)
        nv.push_back(cv[(i+K)%M]);
    for (int i = M; i < N; i++)
        nv.push_back(cv[i]);
}

vector<int> SortDisks(int __N) {
    N = __N;
    for (int i = 0; i < N; i++)
        cv.push_back(i);

    for (int i = N; i >= 1; i--)
    {
        int cval = PutDisks (cv);
        for (int j = 7; j >= 0; j--)
        {
            if ((1 << j) >= i) continue;
            cyc (i, (1 << j));
            int nval = PutDisks (nv);
            if (nval == cval + (1 << j))
            {
                cv = nv;
                cval = nval;
            }
        }
        ans[cv[0]] = cval - N;
        swap (cv[0], cv[i-1]);
        for (int j = i - 1; j < N - 1; j++)
        {
            if (ans[cv[j]] > ans[cv[j+1]])
                swap (cv[j], cv[j+1]);
            else
                break;
        }
    }

    vector <int> res;
    for (int i = 0; i < N; i++)
        res.push_back(ans[i] + 1);
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 10 ms 384 KB Output is correct
11 Correct 11 ms 384 KB Output is correct
12 Correct 10 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 10 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 10 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 10 ms 384 KB Output is correct
11 Correct 11 ms 384 KB Output is correct
12 Correct 10 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 10 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 10 ms 256 KB Output is correct
17 Incorrect 12 ms 256 KB Output isn't correct
18 Halted 0 ms 0 KB -