AtCoder Regular Contest 015

Submission #610771

Source codeソースコード

#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>
using namespace std;

int main(){
	int n, now=0;
	string s[400];
	double t[400][400];

	scanf(" %d", &n);
	for(int i=0; i<400; ++i)
	for(int j=0; j<400; ++j)
	t[i][j]=-1;


	for(int i=0; i<n; ++i){
		string p, q;
		double m;

		cin >> p >> m >> q;

		int x, y;
		bool flag=true;
		for(x=0; x<now; ++x){
			if(s[x]==p){
				flag=false;
				break;
			}
		}

		if(flag){
			s[now++]=p;
		}

		flag=true;
		for(y=0; y<now; ++y){
			if(s[y]==q){
				flag=false;
				break;
			}
		}

		if(flag){
			s[now++]=q;
		}

		t[x][y]=m;
		t[y][x]=1.0/m;
	}

	for(int T=0; T<5; ++T){
		for(int k=0; k<now; ++k){
			for(int i=0; i<now; ++i){
				for(int j=0; j<now; ++j){
					if(t[i][j]>0) continue;

					if(t[i][k]>0){
						if(t[k][j]>0) t[i][j]=t[i][k]*t[k][j];
						if(t[j][k]>0) t[i][j]=t[i][k]/t[j][k];
					}

				}

			}
		}
	}
	/*
	for(int i=0; i<now; ++i){
		for(int j=0; j<now; ++j){
			printf(" %lf", t[i][j]);
		}
		printf("\n");
	}
	*/
	double m=0;
	int ma=0, mb=0;

	for(int i=0; i<now; ++i){
		for(int j=0; j<now; ++j){
			if(m<t[i][j]){
				m=t[i][j];
				ma=i;
				mb=j;
			}
		}
	}

	cout << "1" << s[ma] << "=" << (long)(m+0.001) << s[mb] << endl;

}

Submission

Task問題 C - 変わった単位
User nameユーザ名 imulan
Created time投稿日時
Language言語 C++ (G++ 4.6.4)
Status状態 AC
Score得点 100
Source lengthソースコード長 1343 Byte
File nameファイル名
Exec time実行時間 98 ms
Memory usageメモリ使用量 2208 KB

Compiler messageコンパイルメッセージ

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

Test case

Set

Set name Score得点 / Max score Cases
All 100 / 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_01.txt AC 30 ms 2204 KB
00_sample_02.txt AC 28 ms 2084 KB
00_sample_03.txt AC 29 ms 2196 KB
chokudai_solo_01.txt AC 27 ms 2088 KB
chokudai_solo_02.txt AC 27 ms 2204 KB
chokudai_solo_03.txt AC 28 ms 2204 KB
chokudai_vs_cucumber_01.txt AC 78 ms 2092 KB
chokudai_vs_cucumber_02.txt AC 30 ms 2208 KB
chokudai_vs_cucumber_03.txt AC 30 ms 2200 KB
chokudai_vs_cucumber_04.txt AC 83 ms 2208 KB
chokudai_vs_cucumber_05.txt AC 30 ms 2152 KB
chokudai_vs_kensho_01.txt AC 98 ms 2088 KB
chokudai_vs_kensho_02.txt AC 62 ms 2096 KB
chokudai_vs_kensho_03.txt AC 96 ms 2092 KB
chokudai_vs_kensho_04.txt AC 83 ms 2204 KB
chokudai_vs_kensho_05.txt AC 30 ms 2088 KB
chokudai_vs_kensho_06.txt AC 30 ms 2084 KB
chokudai_vs_kensho_07.txt AC 85 ms 2204 KB
chokudai_vs_kensho_08.txt AC 31 ms 2204 KB
chokudai_vs_kensho_09.txt AC 29 ms 2088 KB
chokudai_vs_laycurse_01.txt AC 95 ms 2092 KB
chokudai_vs_laycurse_02.txt AC 61 ms 2140 KB
chokudai_vs_laycurse_03.txt AC 95 ms 2200 KB
chokudai_vs_sanagipp_01.txt AC 80 ms 2200 KB
chokudai_vs_sanagipp_02.txt AC 87 ms 2092 KB
chokudai_vs_sanagipp_03.txt AC 48 ms 2088 KB
chokudai_vs_sanagipp_04.txt AC 87 ms 2196 KB
chokudai_vs_takahashikun_01.txt AC 29 ms 2204 KB
chokudai_vs_takahashikun_02.txt AC 37 ms 2092 KB
chokudai_vs_takahashikun_03.txt AC 58 ms 2200 KB
chokudai_vs_takahashikun_04.txt AC 94 ms 2096 KB
chokudai_vs_uwitenpen_01.txt AC 87 ms 2084 KB
chokudai_vs_uwitenpen_02.txt AC 43 ms 2084 KB
chokudai_vs_uwitenpen_03.txt AC 86 ms 2088 KB