답안 #850847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850847 2023-09-17T14:25:29 Z tiago Kronican (COCI16_kronican) C++
0 / 100
26 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
#define infinito 999999999
long long int n,k;
long long int v[22][22];
long long int dp[(1<<21)][22];
long long int fib(long long int bitmask, long long 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 17 ms 65536 KB Execution killed with signal 9
2 Runtime error 17 ms 65536 KB Execution killed with signal 9
3 Runtime error 24 ms 65536 KB Execution killed with signal 9
4 Runtime error 17 ms 65536 KB Execution killed with signal 9
5 Runtime error 16 ms 65536 KB Execution killed with signal 9
6 Runtime error 23 ms 65536 KB Execution killed with signal 9
7 Runtime error 18 ms 65536 KB Execution killed with signal 9
8 Runtime error 19 ms 65536 KB Execution killed with signal 9
9 Runtime error 17 ms 65536 KB Execution killed with signal 9
10 Runtime error 26 ms 65536 KB Execution killed with signal 9