結果
問題 |
No.437 cwwゲーム
|
ユーザー |
![]() |
提出日時 | 2016-12-10 20:20:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 895 ms / 2,000 ms |
コード長 | 788 bytes |
コンパイル時間 | 858 ms |
コンパイル使用メモリ | 82,888 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 08:41:02 |
合計ジャッジ時間 | 5,088 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include <iostream> #include <cstdio> #include <string> #include <vector> #include <set> #include <map> #include <algorithm> using namespace std; string N; int dfs(set<int> ss, int sc){ int ans = sc; for(int i=0; i<N.size(); i++){ for(int j=i+1; j<N.size(); j++){ for(int k=j+1; k<N.size(); k++){ set<int> tss = ss; if(ss.find(i) != ss.end() || ss.find(j) != ss.end() || ss.find(k) != ss.end()) continue; if(N[i]!= '0' && N[j]==N[k] && N[i] != N[j]){ tss.insert(i); tss.insert(j); tss.insert(k); int add = 100*(N[i] - '0') + 10*(N[j] - '0') + (N[k] - '0'); ans = max(ans, dfs(tss, sc + add)); } } } } return ans; } int main() { cin>>N; set<int> s; cout<<dfs(s, 0)<<endl; return 0; }