結果
問題 |
No.437 cwwゲーム
|
ユーザー |
![]() |
提出日時 | 2016-10-29 00:51:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,240 bytes |
コンパイル時間 | 694 ms |
コンパイル使用メモリ | 88,492 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 08:27:44 |
合計ジャッジ時間 | 1,864 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:53:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 53 | scanf("%s", str); | ~~~~~^~~~~~~~~~~
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <array> #include <map> #include <queue> #include <limits.h> #include <set> #include <stack> #include <random> #define rep(i,s,n) for(int i = (s); (n) > i; i++) #define REP(i,n) rep(i,0,n) #define RANGE(x,a,b) ((a) <= (x) && (x) <= (b)) #define POWT(x) ((x)*(x)) #define ALL(x) (x).begin(), (x).end() #define MODI 10000 #define bitcheck(a,b) ((a >> b) & 1) #define bitset(a,b) ( a |= (1 << b)) #define bitunset(a,b) (a &= ~(1 << b)) using namespace std; typedef pair<int, int> pii; typedef long long ll; int func(string str) { int ret = 0; int len = str.length(); REP(i, len) { rep(j, i + 1, len) { rep(k, j + 1, len) { if (str[i] != '0' && (str[i] != str[j] )&& (str[j] == str[k])) { string ns(str); ns.erase(ns.begin() + k); ns.erase(ns.begin() + j); ns.erase(ns.begin() + i); int can = (str[i] - '0') * 100 + (str[j] - '0') * 10 + (str[k] - '0'); ret = max(ret, can + func(ns)); } } } } return ret; } signed main() { char str [13]; scanf("%s", str); int ans = func(str); printf("%d\n", ans); return 0; }