結果
| 問題 | No.1284 Flip Game | 
| コンテスト | |
| ユーザー |  platinum | 
| 提出日時 | 2020-09-03 22:36:40 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 721 bytes | 
| コンパイル時間 | 1,479 ms | 
| コンパイル使用メモリ | 170,812 KB | 
| 実行使用メモリ | 13,644 KB | 
| 最終ジャッジ日時 | 2024-11-26 10:38:30 | 
| 合計ジャッジ時間 | 41,682 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 15 TLE * 13 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
using namespace std;
using LL = long long;
const int INF = 1e9;
int c[12][12];
int main(){
	int N, M;
	cin >> N;
	rep(i,N){
		rep(j,N) cin >> c[i][j];
	}
	M=1;
	int ans=INF;
	vector<int> p;
	rep(i,N){
		//if(i==0) rep(j,M) p.emplace_back(i);
		rep(j,M+1) p.emplace_back(i);
	}
	do{
		bool test=true;
		rep(i,N*(M+1)-2){
			if(p[i]==p[i+1]){
				test=false;
				break;
			}
		}
		if(!test) continue;
		int res=0, now=p[0];
		rep(i,N*(M+1)-1){
			int next=p[i+1];
			res+=c[now][next];
			now=next;
		}
		ans=min(ans,res);
	}while(next_permutation(p.begin(),p.end()));
	cout << ans << endl;
	return 0;
}
            
            
            
        