| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 944367 | PaDi | Kronican (COCI16_kronican) | C++14 | 6 ms | 16116 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define pb push_back
#define mp make_pair
#define READS(x); string x;cin >> x;
#define READ(x); int x;cin >> x;
#define DOUREAD(x,y); int x,y;cin >> x >> y;
#define TRIREAD(x,y,z); int x,y,z;cin >> x >> y >> z;
int N,K;
const int MAXN = 22;
const int MASK = 2e6+69;
int dp[MASK];
int C[MAXN][MAXN];
int MAXI = 1e9;
namespace sub1{
    void solve(){
        
    }
}
signed main(){fast
    cin >> N >> K;
    for(int i = 1; i <= N ; i++){
        for(int j = 1; j <= N ; j++){
            cin >> C[i][j];
        }
    }
    for(int i = 1; i <= MASK ; i++){
            dp[i] = 1e9;
        }
        int LIM = pow(2,N)-1;
        dp[LIM] = 0;
        for(int mask = pow(2,N)-1; mask >= 0 ; mask--){
            if(__builtin_popcount(mask) >= K){
                for(int i = 0 ; i < N ; i++){
                    int BIT = mask>>i&1;
                    if(BIT == 1){
                        int SUFMASK = (mask)^(1<<i);
                        for(int j = 0; j < N ; j++){
                            int TIB = mask>>j&1;
                            if(TIB == 0){
                                int PREMASK = mask + pow(2,j);
                                //if(dp[mask]+C[i+1][j+1] == 0) cout << i << " " << j << " " << mask << "LOL\n";
                                dp[mask] = min(dp[mask],dp[PREMASK]+C[j+1][i+1]);
                            }
                        }
                    }
                }
                if(__builtin_popcount(mask) == K) MAXI = min(MAXI,dp[mask]);
            }
        }
        cout << MAXI << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
