結果
問題 |
No.437 cwwゲーム
|
ユーザー |
![]() |
提出日時 | 2020-03-19 10:19:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 985 bytes |
コンパイル時間 | 2,633 ms |
コンパイル使用メモリ | 196,740 KB |
最終ジャッジ日時 | 2025-01-09 07:51:20 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include<bits/stdc++.h> using lint=long long; void cmx(lint&x,lint y){if(x<y)x=y;} int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint n;std::cin>>n; std::vector<lint>a; for(;n;n/=10)a.push_back(n%10); std::reverse(a.begin(),a.end()); n=a.size(); lint N=1ll<<n; std::vector<lint>dp(N); for(lint i=0;i<N;i++){ if(__builtin_popcountll(i)%3!=0)continue; for(lint j=0;j<n;j++){ for(lint k=j+1;k<n;k++){ for(lint l=k+1;l<n;l++){ if(!(i>>j&1)||!(i>>k&1)||!(i>>l&1)|| a.at(j)==0||a.at(j)==a.at(k)||a.at(k)!=a.at(l))continue; cmx(dp.at(i), dp.at(i^1<<j^1<<k^1<<l) +a.at(j)*100+a.at(k)*10+a.at(l)); } } } } std::cout<<*std::max_element(dp.begin(),dp.end())<<'\n'; }