結果

問題 No.938 賢人を探せ
ユーザー coco18000coco18000
提出日時 2019-12-01 23:47:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 872 bytes
コンパイル時間 2,269 ms
コンパイル使用メモリ 181,464 KB
実行使用メモリ 8,244 KB
最終ジャッジ日時 2024-05-08 08:59:42
合計ジャッジ時間 3,561 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
8,240 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 26 ms
6,944 KB
testcase_09 AC 26 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 40 ms
6,956 KB
testcase_12 AC 26 ms
6,940 KB
testcase_13 AC 26 ms
6,940 KB
testcase_14 AC 26 ms
6,944 KB
testcase_15 AC 25 ms
6,940 KB
testcase_16 AC 25 ms
6,940 KB
testcase_17 AC 25 ms
6,944 KB
testcase_18 AC 25 ms
6,944 KB
testcase_19 AC 26 ms
6,944 KB
testcase_20 AC 25 ms
6,944 KB
testcase_21 AC 26 ms
6,944 KB
testcase_22 AC 59 ms
8,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pair<string, string> A[20005];

int main() {
    ll N;
    cin >> N;
    std::map<string, ll> m;
    vector<string> v;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
        if (m[A[i].second] == 0) {
            m[A[i].second] = v.size() + 1;
            v.push_back(A[i].second);
        }
    }

    vector<bool> u(v.size(), false);
    REP(i, N) {
        if (m[A[i].first] == 0)
            continue;
        ll index = m[A[i].first];
        u[index - 1] = true;
    }

    REP(i, v.size()) {
        if (u[i])
            continue;
        cout << v[i] << endl;
    }
    return 0;
}
0