結果

問題 No.938 賢人を探せ
ユーザー kyo1
提出日時 2021-01-12 00:34:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 2,706 ms
コンパイル使用メモリ 204,512 KB
最終ジャッジ日時 2025-01-17 16:16:39
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<string> S;
  map<string, bool> mp;
  for (int i = 0; i < N; i++) {
    string a, b;
    cin >> a >> b;
    S.emplace_back(b);
    mp[a] = false;
    if (mp.find(b) == mp.end() || mp[b]) mp[b] = true;
  }
  for (auto s : S) {
    if (mp[s]) {
      cout << s << '\n';
      mp[s] = false;
    }
  }
  return 0;
}
0