結果
問題 | No.118 門松列(2) |
ユーザー |
![]() |
提出日時 | 2020-08-05 21:12:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 5,000 ms |
コード長 | 1,134 bytes |
コンパイル時間 | 2,116 ms |
コンパイル使用メモリ | 112,780 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 12:12:50 |
合計ジャッジ時間 | 2,908 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:48:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 48 | for(auto [x,y]:mp){ | ^
ソースコード
#include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<string> #include<utility> #include<map> #include<set> #include<queue> #include<stack> #include<functional> #include<math.h> #include<random> #include <bitset> using namespace std; #define N (1000000000+7) //#define N 998244353 #define INF 1e16 typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> Q; const int inf = (int)1e9; ll gcd(ll a, ll b) { if (b > a) { ll tmp = b; b = a; a = tmp; } if (a%b == 0)return b; else return gcd(b, a%b); } ll dp[100010][105][4]; int main(void){ int n; cin>>n; map<int,ll>mp; for(int i=0;i<n;i++){ int a; cin>>a; mp[a]++; } int m = mp.size(); vector<int>a; for(auto [x,y]:mp){ a.push_back(x); } dp[0][0][0]=1; sort(a.begin(),a.end()); ll ans = 0; for(int i=0;i<m;i++){ int lim = a[i]; for(int j=0;j<lim;j++){ for(int k=0;k<=3;k++){ if(k<3)dp[i+1][a[i]][k+1] = (dp[i+1][a[i]][k+1]+mp[lim]*dp[i][j][k])%N; dp[i+1][j][k] = (dp[i+1][j][k]+dp[i][j][k])%N; } } } for(int j=0;j<=100;j++){ ans = (ans+dp[m][j][3])%N; } cout<<ans<<endl; return 0; }