답안 #850843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850843 2023-09-17T13:58:58 Z tiago Kronican (COCI16_kronican) C++14
0 / 100
28 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
#define infinito 99999999
int n,k;
int v[22][22];
int dp[(1<<21)][22];
int fib(int bitmask, int kk){
    if(kk == k){
        return 0;
    }
    else if(dp[bitmask][kk] != infinito){
        return dp[bitmask][kk];
    }
    for(int i = 0; i < n; i++){
        if((bitmask & (1<<i)) == 0){
            for(int y = 0; y < n; y++){
                if((bitmask & (1<<y)) == 0 && y != i ){
                    dp[bitmask][kk] = min(dp[bitmask][kk],  fib((bitmask | (1<<i)), kk-1) + v[i][y]);
                }
            }
        }
    }
    return dp[bitmask][kk];
}
int main(){
    for(int i = 0; i < (1<<21)-1; i++){
        for(int y = 0; y < 22; y++){
            dp[i][y] = infinito;
        }
    }
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        for(int y = 0; y < n; y++){
            cin >> v[i][y];
        }
    }
    cout << fib(0,n);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 65536 KB Execution killed with signal 9
2 Runtime error 22 ms 65536 KB Execution killed with signal 9
3 Runtime error 25 ms 65536 KB Execution killed with signal 9
4 Runtime error 28 ms 65536 KB Execution killed with signal 9
5 Runtime error 23 ms 65536 KB Execution killed with signal 9
6 Runtime error 21 ms 65536 KB Execution killed with signal 9
7 Runtime error 25 ms 65536 KB Execution killed with signal 9
8 Runtime error 22 ms 65536 KB Execution killed with signal 9
9 Runtime error 24 ms 65536 KB Execution killed with signal 9
10 Runtime error 21 ms 65536 KB Execution killed with signal 9