結果

問題 No.437 cwwゲーム
ユーザー algon_320algon_320
提出日時 2016-10-28 23:32:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,182 bytes
コンパイル時間 1,686 ms
コンパイル使用メモリ 172,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 08:12:14
合計ジャッジ時間 2,891 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 WA -
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FORE(x,c) for(auto &x:c)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9; const long long INFLL=1e18;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is>>*i; return is; }
//------------------------------------------------------------------------------

signed main() {
    string a;
    cin>>a;
    vi b;
    FORE(x,a) b.push_back(x-'0');
    int n=SZ(a);

    int ans=0;
    while(true) {
        int c=-1,w=-1;
        RREP(i,10) {
            if(i==0) break;
            // c決める
            REP(j,n) {
                if(b[j]!=i) continue;
                bool ok=false;
                // 後ろに同じ文字が2文字あればwとする
                vector<pair<int,vi>> tmp(10);
                FOR(k,j+1,n) {
                    if(b[k]==-1) continue;
                    tmp[b[k]].first++;
                    tmp[b[k]].second.push_back(k);
                }
                RREP(k,10) {
                    if(tmp[k].first>=2) {
                        w=k;
                        b[tmp[k].second[0]]=-1;
                        b[tmp[k].second[1]]=-1;
                        ok=true;
                        break;
                    }
                }
                if(ok) {
                    c=i;
                    b[j]=-1;
                    goto add;
                }
                break;
            }
        }
        if(c==-1 || w==-1) break;

        add:
        ans+=c*100+w*10+w;
        // dump(c,w,c*100+w*10+w,b);
    }
    cout<<ans<<endl;
    return 0;
}
0