結果

問題 No.523 LED
ユーザー bttb0209bttb0209
提出日時 2017-06-10 17:45:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 667 bytes
コンパイル時間 1,663 ms
コンパイル使用メモリ 166,636 KB
実行使用メモリ 14,800 KB
最終ジャッジ日時 2023-10-24 20:32:51
合計ジャッジ時間 7,944 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'll solve(ll)':
main.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
#define INF 1LL<<63
#define MOD 1000000007

ll n, d, ans, cnt;
ll a[10000000];

bool is_ok() {
	for (ll i = 0; i < n * 2; i++) {
		cnt = 0;
		for (ll j = i; j < n * 2; j++) {
			if (a[i] == a[j]) cnt++;
			if (cnt >= 3) return false;
		}
	}
	return true;
}

ll solve(ll d) {
	if (d >= n * 2 && is_ok()) {
		ans ++;
		ans %= MOD;
		return 0;
	}
	if (d >= n * 2) return 0;
	for (ll i = 0; i < n; i++) {
		a[d-1] = i;
		solve(d + 1);
	}
}

int main() {
	scanf("%lld", &n);
	for (ll i = 0; i < n; i++) {
		a[i] = INF;
	}
	d = 0;
	solve(d);
	printf("%lld\n", ans);
	return 0;
}
0