結果

問題 No.938 賢人を探せ
ユーザー 東前頭十一枚目
提出日時 2019-12-12 11:06:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 1,730 ms
コンパイル使用メモリ 174,992 KB
実行使用メモリ 7,808 KB
最終ジャッジ日時 2024-12-14 11:51:56
合計ジャッジ時間 2,806 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n; cin >> n;
	string a[n], b[n];
	set<string> A;
	for(int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
		A.emplace(a[i]);
	}
	set<string> ans;
	for(int i = 0; i < n; ++i) {
		if(A.find(b[i]) == A.end()) {
			ans.emplace(b[i]);
		}
	}
	for(int i = 0; i < n; ++i) {
		auto itr = ans.find(b[i]);
		if(itr != ans.end()) {
			cout << b[i] << '\n';
			ans.erase(itr);
		}
	}
	return 0;
}
0