結果

問題 No.523 LED
ユーザー bttb0209
提出日時 2017-06-10 17:45:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 667 bytes
コンパイル時間 1,514 ms
コンパイル使用メモリ 165,748 KB
実行使用メモリ 17,096 KB
最終ジャッジ日時 2024-09-24 15:43:47
合計ジャッジ時間 8,010 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 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