結果

問題 No.938 賢人を探せ
ユーザー coco18000coco18000
提出日時 2019-12-01 23:47:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 872 bytes
コンパイル時間 1,897 ms
コンパイル使用メモリ 178,032 KB
実行使用メモリ 8,056 KB
最終ジャッジ日時 2023-08-21 03:31:35
合計ジャッジ時間 3,412 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
8,056 KB
testcase_01 AC 3 ms
4,608 KB
testcase_02 AC 3 ms
4,652 KB
testcase_03 AC 3 ms
4,628 KB
testcase_04 AC 3 ms
4,672 KB
testcase_05 AC 3 ms
4,604 KB
testcase_06 AC 2 ms
4,652 KB
testcase_07 AC 3 ms
4,672 KB
testcase_08 AC 22 ms
6,704 KB
testcase_09 AC 21 ms
6,108 KB
testcase_10 AC 2 ms
4,612 KB
testcase_11 AC 32 ms
6,764 KB
testcase_12 AC 22 ms
6,032 KB
testcase_13 AC 22 ms
6,004 KB
testcase_14 AC 22 ms
6,064 KB
testcase_15 AC 22 ms
6,004 KB
testcase_16 AC 22 ms
6,028 KB
testcase_17 AC 22 ms
6,132 KB
testcase_18 AC 23 ms
6,020 KB
testcase_19 AC 22 ms
6,196 KB
testcase_20 AC 22 ms
6,000 KB
testcase_21 AC 22 ms
6,196 KB
testcase_22 AC 52 ms
8,056 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