| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 380270 | saarang123 | Kronican (COCI16_kronican) | C++17 | 570 ms | 4480 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include <bits/stdc++.h>
using namespace std;
const int mxn = 21;
int dp[1 << mxn], a[mxn][mxn];
signed main() {
    std::ios::sync_with_stdio(0);
    std::cout.tie(0);
    std::cin.tie(0);
    #ifdef saarang
    freopen("/home/saarang/Documents/cp/input.txt", "r", stdin);
    freopen("/home/saarang/Documents/cp/output.txt", "w", stdout);
    #endif
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    	for(int j = 0; j < n; j++)
    		cin >> a[i][j];
    for(int mask = 0; mask < (1 << n); mask++) {
    	if(__builtin_popcount(mask) <= k) {
    		dp[mask] = 0;
    		continue;
    	}
    	dp[mask] = 1e9;
    	for(int i = 0; i < n; i++) if(mask >> i & 1)
    		for(int j = 0; j < n; j++) if(mask >> j & 1) if(i != j)
    			dp[mask] = min(dp[mask], dp[mask ^ (1 << i)] + a[i][j]);
    }
    cout << dp[(1 << n) - 1] << '\n';
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
