結果

問題 No.573 a^2[i] = a[i]
ユーザー startcpp
提出日時 2016-12-26 15:17:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 378 bytes
コンパイル時間 3,057 ms
コンパイル使用メモリ 53,384 KB
実行使用メモリ 22,080 KB
最終ジャッジ日時 2024-12-15 00:07:47
合計ジャッジ時間 118,820 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 TLE * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

//愚直
#include <iostream>
using namespace std;

int n;
int a[100000];

int dfs(int id) {
	int i;
	
	if (id == n) {
		for (i = 0; i < n; i++) if (a[a[i]] != a[i]) return 0;
		return 1;
	}
	
	int ret = 0;
	for (i = 0; i < n; i++) {
		a[id] = i;
		ret += dfs(id + 1);
		ret %= 1000000007;
	}
	return ret;
}

int main() {
	int i;
	cin >> n;
	cout << dfs(0) << endl;	
	return 0;
}
0