結果

問題 No.938 賢人を探せ
ユーザー misora192misora192
提出日時 2020-07-17 12:44:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 1,835 ms
コンパイル使用メモリ 179,336 KB
実行使用メモリ 8,088 KB
最終ジャッジ日時 2023-08-21 03:45:47
合計ジャッジ時間 3,334 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
8,088 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 21 ms
5,484 KB
testcase_09 AC 24 ms
5,468 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 29 ms
5,464 KB
testcase_12 AC 23 ms
5,552 KB
testcase_13 AC 24 ms
5,460 KB
testcase_14 AC 25 ms
5,488 KB
testcase_15 AC 24 ms
5,480 KB
testcase_16 AC 24 ms
5,492 KB
testcase_17 AC 24 ms
5,548 KB
testcase_18 AC 26 ms
5,540 KB
testcase_19 AC 24 ms
5,480 KB
testcase_20 AC 25 ms
5,464 KB
testcase_21 AC 24 ms
5,468 KB
testcase_22 AC 36 ms
8,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	int cnt = 0;
	map<string, int> mp;
	vector<int> v;
	vector<string> nm;
	rep(i, n){
		string s, t;
		cin >> s >> t;

		if(mp.count(t) == 0) {
			mp[t] = cnt;
			cnt++;
			v.push_back(-1);
			nm.push_back(t);
		}

		if(mp.count(s) == 0){
			mp[s] = cnt;
			cnt++;
			v.push_back(-1);
			nm.push_back(s);
		}

		v[mp[s]] = mp[t];
	}

	int m = v.size();
	rep(i, m){
		if(v[i] == -1){
			cout << nm[i] << "\n";
		}
	}
}
0