結果

問題 No.938 賢人を探せ
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-12-01 01:57:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 3,466 ms
コンパイル使用メモリ 156,796 KB
実行使用メモリ 7,752 KB
最終ジャッジ日時 2023-08-21 03:28:37
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
7,752 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 26 ms
5,356 KB
testcase_09 AC 30 ms
5,300 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 36 ms
5,544 KB
testcase_12 AC 33 ms
5,320 KB
testcase_13 AC 33 ms
5,404 KB
testcase_14 AC 33 ms
5,340 KB
testcase_15 AC 32 ms
5,408 KB
testcase_16 AC 33 ms
5,472 KB
testcase_17 AC 32 ms
5,460 KB
testcase_18 AC 32 ms
5,296 KB
testcase_19 AC 33 ms
5,472 KB
testcase_20 AC 33 ms
5,340 KB
testcase_21 AC 34 ms
5,328 KB
testcase_22 AC 66 ms
7,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int n; cin >> n;
    map<string, int> mp;
    vector<string> ans;
    REP(i, n) {
        string s, t; cin >> s >> t;
        if (mp.find(s) == mp.end()) ans.push_back(s);
        if (mp.find(t) == mp.end()) ans.push_back(t);
        mp[s] = -1;
        if (mp.find(t) == mp.end() || mp[t] != -1) mp[t] = 1;
    }
    REP(i, ans.size()) {
        if (mp[ans[i]] == 1) {
            cout << ans[i] << endl;
        }
    }
    return 0;
}
0