답안 #619610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
619610 2022-08-02T13:36:13 Z Sergio_2357 고대 책들 (IOI17_books) C++17
0 / 100
2000 ms 300 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;

int n;
int l = 0;
int h = -1;
vi a;

int bst = INT_MAX;

bool correct()
{
    bool r = true;
    for (int i = 0; i < n; i++)
        if (a[i] != i)
            r = false;
    return r;
}

void bk(int p, int d)
{
    //cout << d << endl;
    if (p == 0 && correct()) {
        bst = min(bst, l);
        return;
    }
    if (l >= bst || d >= 10)
        return;
    for (int i = 0; i < n; i++) {
        if (i == p)
            continue;
        l += abs(p - i);
        swap(h, a[p]);
        bk(i, d + 1);
        swap(h, a[p]);
        bk(i, d + 1);
        l -= abs(p - i);
    }
}

long long minimum_walk(vector<int> p, int s)
{
    //cout << "HELLO" << endl;
    n = p.size();
    for (int x : p)
        a.push_back(x);
    bk(0, 0);
    return bst;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 8 ms 300 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 8 ms 300 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 8 ms 300 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2087 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 8 ms 300 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
4 Halted 0 ms 0 KB -