結果

問題 No.938 賢人を探せ
ユーザー ohreitetsuohreitetsu
提出日時 2019-12-06 21:31:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 1,009 ms
コンパイル使用メモリ 82,964 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-05-08 09:03:08
合計ジャッジ時間 2,199 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
8,192 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 19 ms
5,376 KB
testcase_09 AC 21 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 28 ms
5,376 KB
testcase_12 AC 24 ms
5,376 KB
testcase_13 AC 23 ms
5,376 KB
testcase_14 AC 23 ms
5,376 KB
testcase_15 AC 22 ms
5,376 KB
testcase_16 AC 22 ms
5,376 KB
testcase_17 AC 23 ms
5,376 KB
testcase_18 AC 23 ms
5,376 KB
testcase_19 AC 23 ms
5,376 KB
testcase_20 AC 24 ms
5,376 KB
testcase_21 AC 23 ms
5,376 KB
testcase_22 AC 63 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	map<string,int> ABMap;
	map<string,int>::iterator mit;
	string A,B;
	for (i=1;i<=N;i++){
		cin>>A>>B;
		mit=ABMap.find(A);
		if (mit==ABMap.end()){
			ABMap[A]=0;
		}else{
			(*mit).second=0;
		}
		mit=ABMap.find(B);
		if (mit==ABMap.end()){
			ABMap[B]=i;
		}
	}
	map<int,string> abMap;
	map<int,string>::iterator mit1;
	for (mit=ABMap.begin();mit!=ABMap.end();mit++){
		if ((*mit).second!=0){
			abMap[(*mit).second]=(*mit).first;
		}
	}
	for (mit1=abMap.begin();mit1!=abMap.end();mit1++){
		cout<<(*mit1).second<<endl;
	}
	return 0;
}
0