Submission #105737


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,double> P;
map<string,int> M;
map<int,string> O;
vector<P> G[500];
int in[500];
int X=0,Y=0,ans=0;
void solve(int x,double y) {
	if(G[x].size()==0) {if(y>ans) {ans=y,Y=x;} return ;}
	for(int i=0;i<G[x].size();i++) {
		solve(G[x][i].first,y*G[x][i].second);
	}
}
int main() {
	int N,cnt=0;
	cin>>N;
	for(int i=0;i<N;i++) {
		string Large,Small; double m;
		cin>>Large>>m>>Small;
		if(M.find(Large)==M.end()) {O[cnt]=Large,M[Large]=cnt++;}
		if(M.find(Small)==M.end()) {O[cnt]=Small,M[Small]=cnt++;}
		G[M[Large]].push_back(P(M[Small],m));
		in[M[Small]]++;
	}
	vector<int> S;
	for(int i=0;i<cnt;i++) if(in[i]==0) S.push_back(i);
	for(int i=0;i<S.size();i++) {
		int _a=ans;
		solve(S[i],1);
		if(ans>_a) X=S[i];
	}
	cout<<1<<O[X]<<'='<<ans<<O[Y]<<endl;
}

Submission Info

Submission Time
Task C - 変わった単位
User Div9851
Language C++ (G++ 4.6.4)
Score 0
Code Size 940 Byte
Status
Exec Time 276 ms
Memory 16816 KB

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 100 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, chokudai_solo_01.txt, chokudai_solo_02.txt, chokudai_solo_03.txt, chokudai_vs_cucumber_01.txt, chokudai_vs_cucumber_02.txt, chokudai_vs_cucumber_03.txt, chokudai_vs_cucumber_04.txt, chokudai_vs_cucumber_05.txt, chokudai_vs_kensho_01.txt, chokudai_vs_kensho_02.txt, chokudai_vs_kensho_03.txt, chokudai_vs_kensho_04.txt, chokudai_vs_kensho_05.txt, chokudai_vs_kensho_06.txt, chokudai_vs_kensho_07.txt, chokudai_vs_kensho_08.txt, chokudai_vs_kensho_09.txt, chokudai_vs_laycurse_01.txt, chokudai_vs_laycurse_02.txt, chokudai_vs_laycurse_03.txt, chokudai_vs_sanagipp_01.txt, chokudai_vs_sanagipp_02.txt, chokudai_vs_sanagipp_03.txt, chokudai_vs_sanagipp_04.txt, chokudai_vs_takahashikun_01.txt, chokudai_vs_takahashikun_02.txt, chokudai_vs_takahashikun_03.txt, chokudai_vs_takahashikun_04.txt, chokudai_vs_uwitenpen_01.txt, chokudai_vs_uwitenpen_02.txt, chokudai_vs_uwitenpen_03.txt
Case Name Status Exec Time Memory
00_sample_01.txt 22 ms 916 KB
00_sample_02.txt 22 ms 928 KB
00_sample_03.txt 22 ms 880 KB
chokudai_solo_01.txt 23 ms 812 KB
chokudai_solo_02.txt 22 ms 804 KB
chokudai_solo_03.txt 22 ms 928 KB
chokudai_vs_cucumber_01.txt 22 ms 924 KB
chokudai_vs_cucumber_02.txt 272 ms 16796 KB
chokudai_vs_cucumber_03.txt 260 ms 16816 KB
chokudai_vs_cucumber_04.txt 23 ms 920 KB
chokudai_vs_cucumber_05.txt 255 ms 16804 KB
chokudai_vs_kensho_01.txt 24 ms 924 KB
chokudai_vs_kensho_02.txt 23 ms 928 KB
chokudai_vs_kensho_03.txt 22 ms 928 KB
chokudai_vs_kensho_04.txt 22 ms 928 KB
chokudai_vs_kensho_05.txt 265 ms 16808 KB
chokudai_vs_kensho_06.txt 264 ms 16808 KB
chokudai_vs_kensho_07.txt 276 ms 16812 KB
chokudai_vs_kensho_08.txt 265 ms 16812 KB
chokudai_vs_kensho_09.txt 21 ms 924 KB
chokudai_vs_laycurse_01.txt 22 ms 924 KB
chokudai_vs_laycurse_02.txt 23 ms 924 KB
chokudai_vs_laycurse_03.txt 22 ms 912 KB
chokudai_vs_sanagipp_01.txt 23 ms 920 KB
chokudai_vs_sanagipp_02.txt 27 ms 812 KB
chokudai_vs_sanagipp_03.txt 22 ms 816 KB
chokudai_vs_sanagipp_04.txt 22 ms 928 KB
chokudai_vs_takahashikun_01.txt 20 ms 920 KB
chokudai_vs_takahashikun_02.txt 22 ms 928 KB
chokudai_vs_takahashikun_03.txt 22 ms 924 KB
chokudai_vs_takahashikun_04.txt 22 ms 928 KB
chokudai_vs_uwitenpen_01.txt 22 ms 924 KB
chokudai_vs_uwitenpen_02.txt 21 ms 928 KB
chokudai_vs_uwitenpen_03.txt 22 ms 920 KB