結果
| 問題 |
No.118 門松列(2)
|
| ユーザー |
m1025o1184t
|
| 提出日時 | 2019-12-02 03:05:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 924 bytes |
| コンパイル時間 | 1,591 ms |
| コンパイル使用メモリ | 170,644 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-11-22 05:30:45 |
| 合計ジャッジ時間 | 71,388 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 3 RE * 12 TLE * 9 |
コンパイルメッセージ
main.cpp: In function 'void comb()':
main.cpp:14:57: warning: iteration 498 invokes undefined behavior [-Waggressive-loop-optimizations]
14 | C[i + 1][j + 1] = C[i][j] % mod + C[i][j + 1] % mod;
| ~~~~~~~~~~^
main.cpp:12:22: note: within this loop
12 | for(int j=1;j<=499;++j){
| ~^~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const int mod = 1000000007;
int C[500][500];
void comb(){
C[1][1] = 1;
for(int i= 1;i<=499;++i){
for(int j=1;j<=499;++j){
C[i + 1][j] = C[i][j] % mod+ C[i][j - 1] % mod;
C[i + 1][j + 1] = C[i][j] % mod + C[i][j + 1] % mod;
}
}
}
int main(){
int n;
cin >> n;
vector<int> A(n);
rep(i,n) cin >> A[i];
comb();
vector<int> res = A;
auto result = unique(res.begin(),res.end());
res.erase(result,res.end());
if(res.size() == A.size()){
int ans = C[n][3] % mod;
cout << ans << endl;
return 0;
}
int sol = 1;
for(int i=0;i<res.size();++i){
int k = count(A.begin(),A.end(),res[i]);
sol *= k;
sol %= mod;
}
int ans2 = C[res.size()][3] * sol % mod;
cout << ans2 << endl;
return 0;
}
m1025o1184t