結果
問題 | No.562 超高速一人かるた small |
ユーザー | どらら |
提出日時 | 2017-08-25 23:58:59 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 758 ms / 3,000 ms |
コード長 | 1,577 bytes |
コンパイル時間 | 1,552 ms |
コンパイル使用メモリ | 166,340 KB |
実行使用メモリ | 20,044 KB |
最終ジャッジ日時 | 2024-04-23 16:20:22 |
合計ジャッジ時間 | 11,227 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 3 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 6 ms
6,940 KB |
testcase_08 | AC | 75 ms
6,988 KB |
testcase_09 | AC | 741 ms
19,920 KB |
testcase_10 | AC | 167 ms
8,652 KB |
testcase_11 | AC | 343 ms
13,384 KB |
testcase_12 | AC | 76 ms
6,944 KB |
testcase_13 | AC | 4 ms
6,944 KB |
testcase_14 | AC | 758 ms
20,044 KB |
testcase_15 | AC | 746 ms
20,044 KB |
testcase_16 | AC | 751 ms
19,916 KB |
testcase_17 | AC | 733 ms
19,920 KB |
testcase_18 | AC | 734 ms
20,040 KB |
testcase_19 | AC | 742 ms
20,040 KB |
testcase_20 | AC | 752 ms
19,916 KB |
testcase_21 | AC | 753 ms
19,916 KB |
testcase_22 | AC | 749 ms
19,920 KB |
testcase_23 | AC | 758 ms
20,040 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; #define MOD 1000000007 ll dp[(1<<20)+5]; ll cnt[(1<<20)+5]; int N; string text[25]; ll diff[25][25]; ll ret[25]; int main(){ cin >> N; rep(i,N){ cin >> text[i]; } dp[0] = 0; cnt[0] = 1; rep(i,N){ rep(j,N){ int p = 0; while(true){ if(p == text[i].size()){ diff[i][j] = p+1; break; } if(p == text[j].size()){ diff[i][j] = p+1; break; } if(text[i][p] != text[j][p]){ diff[i][j] = p+1; break; } p++; } } } for(ll S=0; S<(1LL<<N); S++){ rep(i,N) if(((S>>i)&1) == 0){ ll x = 0; rep(j,N) if(i!=j) if(((S>>j)&1) == 0) { x = max(x, diff[i][j]); } if(x == 0) x = 1; dp[S | (1<<i)] += dp[S] + x * cnt[S]; dp[S | (1<<i)] %= MOD; cnt[S | (1<<i)] += cnt[S]; cnt[S | (1<<i)] %= MOD; } } for(ll S=0; S<(1LL<<N); S++){ int x = 0; rep(i,N) if((S>>i)&1) x++; ret[x] += dp[S]; ret[x] %= MOD; } REP(i,1,N+1){ cout << ret[i] << endl; } /* for(ll S=0; S<(1LL<<N); S++){ rep(i,N){ if((S>>i)&1) cout << 1; else cout << 0; } cout << "\t" << dp[S] << "\t" << cnt[S] << endl; } */ return 0; }