結果

問題 No.938 賢人を探せ
ユーザー ohreitetsuohreitetsu
提出日時 2019-12-06 21:31:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 1,104 ms
コンパイル使用メモリ 83,992 KB
実行使用メモリ 8,016 KB
最終ジャッジ日時 2023-08-21 03:35:52
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
8,016 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 18 ms
4,644 KB
testcase_09 AC 20 ms
4,692 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 24 ms
5,040 KB
testcase_12 AC 22 ms
5,060 KB
testcase_13 AC 21 ms
5,096 KB
testcase_14 AC 23 ms
4,920 KB
testcase_15 AC 21 ms
4,840 KB
testcase_16 AC 22 ms
4,848 KB
testcase_17 AC 22 ms
4,852 KB
testcase_18 AC 21 ms
4,900 KB
testcase_19 AC 22 ms
5,120 KB
testcase_20 AC 22 ms
4,840 KB
testcase_21 AC 22 ms
4,848 KB
testcase_22 AC 62 ms
8,008 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