結果

問題 No.1284 Flip Game
ユーザー 👑 platinumplatinum
提出日時 2020-09-03 22:36:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 721 bytes
コンパイル時間 1,875 ms
コンパイル使用メモリ 169,104 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-04 20:26:03
合計ジャッジ時間 5,583 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 106 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 106 ms
5,376 KB
testcase_14 AC 106 ms
5,376 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0