東京大学プログラミングコンテスト2014

Submission #3450515

Source codeソースコード

#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
struct node{
  ll to[10];
  ll sum;
  ll max;
};
 
vector<node> v(2);
node t;
string a;
ll b;
ll dfs(ll n,ll k){
  if(k>=a.size()){
    v[n].sum+=b;
    return v[n].max+v[n].sum;
  }
  
  ll ta=a[k]-'0';
  if(v[n].to[ta]==0){
    v[n].to[ta]=v.size();
    v.push_back(t);
  }
 
  v[n].max=max(v[n].max,dfs(v[n].to[ta],k+1));
  return v[n].sum+v[n].max;
}
 
int main(){
  ll n;
  cin>>n;
  for(ll i=0;i<n;i++){
    cin>>a>>b;
    reverse(a.begin(),a.end());
    cout<<dfs(1,0)<<endl;
  }
  return 0;
}

Submission

Task問題 E - 宝くじ
User nameユーザ名 shake
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 RE
Score得点 0
Source lengthソースコード長 611 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
All 0 / 200 scrambled_00.txt,scrambled_01.txt,scrambled_02.txt,scrambled_03.txt,scrambled_04.txt,scrambled_05.txt,scrambled_06.txt,scrambled_07.txt,scrambled_08.txt,scrambled_09.txt,scrambled_10.txt,scrambled_11.txt,scrambled_12.txt,scrambled_13.txt,scrambled_14.txt,scrambled_15.txt,scrambled_16.txt,scrambled_17.txt,scrambled_18.txt,scrambled_19.txt,scrambled_20.txt,scrambled_21.txt,scrambled_22.txt,scrambled_23.txt,scrambled_24.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
scrambled_00.txt AC 1 ms 256 KB
scrambled_01.txt WA
scrambled_02.txt WA
scrambled_03.txt WA
scrambled_04.txt WA
scrambled_05.txt WA
scrambled_06.txt WA
scrambled_07.txt WA
scrambled_08.txt WA
scrambled_09.txt WA
scrambled_10.txt WA
scrambled_11.txt WA
scrambled_12.txt WA
scrambled_13.txt WA
scrambled_14.txt RE
scrambled_15.txt RE
scrambled_16.txt RE
scrambled_17.txt RE
scrambled_18.txt RE
scrambled_19.txt RE
scrambled_20.txt RE
scrambled_21.txt RE
scrambled_22.txt RE
scrambled_23.txt RE
scrambled_24.txt RE