Submission #308048


Source Code Expand

Copy
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
vector<string> v;
vector<P> g[400];
map<string,int> mp;
char large[11],small[11];
P memo[400];
P solve(int idx) {
	if(memo[idx].first!=1) {
		return memo[idx];
	}
	for(int i=0;i<g[idx].size();i++) {
		P ret=solve(g[idx][i].first);
		ret.first*=g[idx][i].second;
		memo[idx]=max(memo[idx],ret);
	}
	return memo[idx];
}
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		int m;
		scanf("%s %d %s",large,&m,small);
		int l , s;
		if(mp.find(large)==mp.end()) {
			l=mp.size();
			v.push_back(large);
			mp[large]=l;
		}else {
			l=mp[large];
		}
		if(mp.find(small)==mp.end()) {
			s=mp.size();
			v.push_back(small);
			mp[small]=s;
		}else {
			s=mp[small];
		}
		g[l].push_back(P(s,m));
	}
	for(int i=0;i<v.size();i++) {
		memo[i]=P(1,i);
	}
	int ans=0;
	int l ,r;
	for(int i=0;i<v.size();i++) {
		P ret=solve(i);
		if(ans<ret.first) {
			ans=ret.first;
			l=i,r=ret.second;
		}
	}
	printf("PRO\n");
	//printf("1%s=%d%s\n",v[l].c_str(),ans,v[r].c_str());
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:28:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:31:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

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 27 ms 1076 KB
00_sample_02.txt 29 ms 948 KB
00_sample_03.txt 27 ms 968 KB
chokudai_solo_01.txt 27 ms 1024 KB
chokudai_solo_02.txt 300 ms 16980 KB
chokudai_solo_03.txt 300 ms 16984 KB
chokudai_vs_cucumber_01.txt 29 ms 1008 KB
chokudai_vs_cucumber_02.txt 300 ms 16948 KB
chokudai_vs_cucumber_03.txt 302 ms 17012 KB
chokudai_vs_cucumber_04.txt 302 ms 17012 KB
chokudai_vs_cucumber_05.txt 301 ms 17012 KB
chokudai_vs_kensho_01.txt 29 ms 1020 KB
chokudai_vs_kensho_02.txt 27 ms 980 KB
chokudai_vs_kensho_03.txt 30 ms 1020 KB
chokudai_vs_kensho_04.txt 27 ms 1024 KB
chokudai_vs_kensho_05.txt 303 ms 16968 KB
chokudai_vs_kensho_06.txt 306 ms 17016 KB
chokudai_vs_kensho_07.txt 30 ms 1016 KB
chokudai_vs_kensho_08.txt 306 ms 16980 KB
chokudai_vs_kensho_09.txt 305 ms 16976 KB
chokudai_vs_laycurse_01.txt 30 ms 960 KB
chokudai_vs_laycurse_02.txt 27 ms 1024 KB
chokudai_vs_laycurse_03.txt 28 ms 980 KB
chokudai_vs_sanagipp_01.txt 27 ms 1020 KB
chokudai_vs_sanagipp_02.txt 29 ms 1016 KB
chokudai_vs_sanagipp_03.txt 29 ms 1016 KB
chokudai_vs_sanagipp_04.txt 31 ms 952 KB
chokudai_vs_takahashikun_01.txt 30 ms 956 KB
chokudai_vs_takahashikun_02.txt 27 ms 1024 KB
chokudai_vs_takahashikun_03.txt 28 ms 1020 KB
chokudai_vs_takahashikun_04.txt 27 ms 1004 KB
chokudai_vs_uwitenpen_01.txt 28 ms 1012 KB
chokudai_vs_uwitenpen_02.txt 31 ms 932 KB
chokudai_vs_uwitenpen_03.txt 28 ms 984 KB