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

Submission #6545608

Source codeソースコード

#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
map<string,ll> mp;

int main(){
	cin>>n;
	mp[""]=0;
	for(int i=0;i<n;i++){
		string s;
		ll x;
		cin>>s>>x;
		reverse(s.begin(),s.end());
		string t=s;
		mp[t]+=x;
		while(t!=""){
			string t_=t.substr(0,(int)t.size()-1);
			ll tmp=mp[t_];
			mp[t_]=max(tmp,mp[t]);
			t=t_;
		}
		cout<<mp[""]<<endl;
	}
}

Submission

Task問題 E - 宝くじ
User nameユーザ名 Pulmn
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1036 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 WA
scrambled_01.txt AC 1 ms 256 KB
scrambled_02.txt AC 540 ms 1664 KB
scrambled_03.txt AC 485 ms 1536 KB
scrambled_04.txt AC 579 ms 1792 KB
scrambled_05.txt AC 409 ms 1152 KB
scrambled_06.txt AC 474 ms 1280 KB
scrambled_07.txt AC 149 ms 512 KB
scrambled_08.txt AC 242 ms 768 KB
scrambled_09.txt WA
scrambled_10.txt WA
scrambled_11.txt WA
scrambled_12.txt WA
scrambled_13.txt WA
scrambled_14.txt WA
scrambled_15.txt WA
scrambled_16.txt WA
scrambled_17.txt WA
scrambled_18.txt WA
scrambled_19.txt AC 1347 ms 57088 KB
scrambled_20.txt AC 1650 ms 51200 KB
scrambled_21.txt AC 996 ms 33664 KB
scrambled_22.txt WA
scrambled_23.txt AC 172 ms 8064 KB
scrambled_24.txt WA