| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 884567 | vjudge1 | Kronican (COCI16_kronican) | C++17 | 1349 ms | 8800 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
    #include <bits/stdc++.h>
    using namespace std;
    #define int long long
    const int mod = 1e9 + 7;
    const int maxn = 21;
    const int infinito = 1e9;
    int n,k;
    int v[maxn][maxn];
    int dp[1<<maxn];
    int contaum(int g){
    	int x =0;
    	while(g > 0){
    		x++;
    		g = g - (g&(-g));
    	}
    	return x;
    }
    signed main(){
    	cin >> n >> k;
    	for(int i = 0; i < n; i++){
    		for(int y = 0; y < n; y++){
    			cin >> v[i][y];
    		}
    	}
    	dp[0] = 0;
    	for(int i = 1; i < (1<<n); i++){
    		int uns = contaum(i);
    		if(uns <= k){
    			dp[i] = 0;
     
    		}
    		else{
    			//cout << i << " ";
    			dp[i] = infinito;
    			for(int y = 0; y < n; y++){
    				for(int j = 0; j < n; j++){
    					if(j != y){
    						//cout << y << " " << j <<  " " << (i&(1<<j)) << " " <<  (i&(1<<y)) << endl;
    						if(((i&(1<<j)) >= 1) && ((i&(1<<y)) >= 1)){
    							//cout << "oi" << endl;
    							dp[i] = min(dp[i],  dp[i^(1<<y)] + v[y][j]);
    						}
    					}
    				}
    			}
    		}
    	}
    	cout << dp[(1<<n) - 1] << endl;
    	return 0;
    }
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
