Submission #105449


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int,int> 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,int 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; int m;
		cin>>Large>>m>>Small;
		if(M.find(Large)!=M.end()&&M.find(Small)!=M.end()) continue;
		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 A - Celsius と Fahrenheit
User Div9851
Language C++ (G++ 4.6.4)
Score 0
Code Size 995 Byte
Status
Exec Time 23 ms
Memory 932 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, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt
Case Name Status Exec Time Memory
00_sample_01.txt 21 ms 792 KB
00_sample_02.txt 22 ms 800 KB
00_sample_03.txt 21 ms 796 KB
test_01.txt 21 ms 804 KB
test_02.txt 21 ms 812 KB
test_03.txt 21 ms 804 KB
test_04.txt 21 ms 804 KB
test_05.txt 21 ms 800 KB
test_06.txt 21 ms 748 KB
test_07.txt 21 ms 800 KB
test_08.txt 21 ms 804 KB
test_09.txt 23 ms 752 KB
test_10.txt 21 ms 816 KB
test_11.txt 21 ms 808 KB
test_12.txt 20 ms 804 KB
test_13.txt 21 ms 928 KB
test_14.txt 22 ms 928 KB
test_15.txt 21 ms 924 KB
test_16.txt 20 ms 932 KB
test_17.txt 20 ms 804 KB
test_18.txt 22 ms 808 KB
test_19.txt 21 ms 808 KB
test_20.txt 22 ms 924 KB