結果

問題 No.938 賢人を探せ
ユーザー kyo1kyo1
提出日時 2021-01-12 00:34:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 211,088 KB
実行使用メモリ 6,696 KB
最終ジャッジ日時 2023-08-21 03:48:34
合計ジャッジ時間 3,535 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
6,696 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 18 ms
5,368 KB
testcase_09 AC 22 ms
5,316 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 26 ms
5,432 KB
testcase_12 AC 22 ms
4,860 KB
testcase_13 AC 22 ms
4,896 KB
testcase_14 AC 22 ms
4,884 KB
testcase_15 AC 22 ms
4,864 KB
testcase_16 AC 22 ms
4,864 KB
testcase_17 AC 22 ms
4,880 KB
testcase_18 AC 22 ms
4,860 KB
testcase_19 AC 22 ms
5,012 KB
testcase_20 AC 21 ms
4,856 KB
testcase_21 AC 22 ms
4,980 KB
testcase_22 AC 28 ms
6,692 KB
権限があれば一括ダウンロードができます

ソースコード

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