답안 #434747

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
434747 2021-06-21T16:50:47 Z Monchito 고대 책들 (IOI17_books) C++14
12 / 100
1 ms 332 KB
#include "books.h"
#include <iostream>
using namespace std;
using ll = long long;

vector<pair<vector<int>, int>> x[4];

void calc() {
    //n = 1, s=0
    x[0].push_back( { { 0 } , 0 } );

    //n = 2, s=0
    x[1].push_back( { { 0, 1 } , 0 } );
    x[1].push_back( { { 1, 0 } , 2 } );

    
    //n = 3, s=0
    x[2].push_back( { { 0, 1, 2 } , 0 } );
    x[2].push_back( { { 0, 2, 1 } , 4 } );
    x[2].push_back( { { 1, 0, 2 } , 2 } );
    x[2].push_back( { { 2, 1, 0 } , 4 } );
    x[2].push_back( { { 2, 0, 1 } , 4 } );
    x[2].push_back( { { 1, 2, 0 } , 4 } );


    //n = 4, s=0
    x[3].push_back( { { 0, 1, 2, 3 } , 0 } );
    x[3].push_back( { { 1, 0, 2, 3 } , 2 } );
    x[3].push_back( { { 0, 1, 3, 2 } , 6 } );
    x[3].push_back( { { 1, 0, 3, 2 } , 8 } );
    x[3].push_back( { { 0, 2, 1, 3 } , 4 } );
    x[3].push_back( { { 3, 2, 1, 0 } , 8 } );
    x[3].push_back( { { 3, 1, 2, 0 } , 6 } );
    x[3].push_back( { { 2, 1, 0, 3 } , 4 } );
    x[3].push_back( { { 2, 3, 0, 1 } , 8 } );
    x[3].push_back( { { 0, 2, 3, 1 } , 6 } );
    x[3].push_back( { { 1, 2, 3, 0 } , 6 } );
    x[3].push_back( { { 1, 3, 2, 0 } , 6 } );
    x[3].push_back( { { 0, 3, 2, 1 } , 6 } );
    x[3].push_back( { { 1, 3, 0, 2 } , 6 } );
    x[3].push_back( { { 2, 3, 1, 0 } , 8 } );
    x[3].push_back( { { 0, 3, 1, 2 } , 6 } );
    x[3].push_back( { { 3, 2, 0, 1 } , 8 } );
    x[3].push_back( { { 2, 1, 3, 0 } , 6 } );
    x[3].push_back( { { 3, 1, 0, 2 } , 6 } );
    x[3].push_back( { { 1, 2, 0, 3 } , 4 } );
    x[3].push_back( { { 2, 0, 1, 3 } , 4 } );
    x[3].push_back( { { 2, 0, 3, 1 } , 6 } );
    x[3].push_back( { { 3, 0, 1, 2 } , 6 } );
    x[3].push_back( { { 3, 0, 2, 1 } , 6 } );
}

ll minimum_walk(vector<int> p, int s) {
    calc();
    int n = (int)p.size();

    for(int i=0; i<(int)x[n-1].size(); i++) {
        bool can = true;

        for(int j=0; j<n; j++) {
            if(x[n-1][i].first[j] != p[j]) can = false;
        }

        if(can) return x[n-1][i].second;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 292 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 292 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Runtime error 1 ms 332 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 292 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Runtime error 1 ms 332 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 292 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 292 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Runtime error 1 ms 332 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -