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

Submission #3426091

Source codeソースコード

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

Submission

Task問題 E - 宝くじ
User nameユーザ名 shake
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 RE
Score得点 0
Source lengthソースコード長 634 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 RE
scrambled_03.txt RE
scrambled_04.txt RE
scrambled_05.txt RE
scrambled_06.txt RE
scrambled_07.txt RE
scrambled_08.txt RE
scrambled_09.txt WA
scrambled_10.txt WA
scrambled_11.txt RE
scrambled_12.txt RE
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