# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
98535 | dalgerok | Kronican (COCI16_kronican) | C++17 | 749 ms | 4600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, m;
cin >> n >> m;
int a[n][n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cin >> a[i][j];
}
}
int dp[(1 << n)];
memset(dp, 63, sizeof(dp));
dp[(1 << n) - 1] = 0;
for(int i = (1 << n) - 1; i >= 0; i--){
for(int j = 0; j < n; j++){
if((i >> j) & 1){
for(int k = 0; k < n; k++){
if(j == k){
continue;
}
if((i >> k) & 1){
dp[i ^ (1 << j)] = min(dp[i ^ (1 << j)], dp[i] + a[j][k]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |