結果
問題 | No.437 cwwゲーム |
ユーザー |
![]() |
提出日時 | 2017-05-18 20:13:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 1,058 bytes |
コンパイル時間 | 1,437 ms |
コンパイル使用メモリ | 134,376 KB |
最終ジャッジ日時 | 2025-01-05 00:21:53 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#include <cstdio> #include <cstring> #include <cmath> #include <random> #include <vector> #include <algorithm> #include <array> #include <functional> #include <utility> #include <regex> #include <tuple> #include <map> using namespace std; int solve(string s,int na=0){ if(s.size()<3){ return 0; } vector<int> score; int size=s.size(); for(int a=na;a<size-2;a++){ for(int b=a+1;b<size-1;b++){ for(int c=b+1;c<size;c++){ array<char,4> d={s[a],s[b],s[c],0}; bool iscww=false; if(d[0]!='0'&&d[0]!=d[1]&&d[0]!=d[2]&&d[1]==d[2]){ iscww=true; } if(iscww){ string t(d.data()); //printf("a=%d,b=%d,c=%d,slen=%lu,s=%s,t=%s\n",a,b,c,score.size(),s.c_str(),t.c_str()); int ts=stoi(t); string ns(s); ns.erase(c,1); ns.erase(b,1); ns.erase(a,1); score.push_back(ts+solve(ns,a)); } } } } if(score.size()==0) return 0; return *max_element(score.begin(),score.end()); } int main(){ char n[24]; -scanf("%s",n); string m=n; int score=solve(m); printf("%d\n",score); return 0; }