結果

問題 No.938 賢人を探せ
ユーザー xardasxardas
提出日時 2019-12-21 13:20:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 1,107 ms
コンパイル使用メモリ 91,424 KB
実行使用メモリ 8,344 KB
最終ジャッジ日時 2023-08-21 03:41:09
合計ジャッジ時間 2,453 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
8,344 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 20 ms
6,472 KB
testcase_09 AC 21 ms
6,284 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 27 ms
6,672 KB
testcase_12 AC 25 ms
5,612 KB
testcase_13 AC 24 ms
5,532 KB
testcase_14 AC 25 ms
5,528 KB
testcase_15 AC 25 ms
5,636 KB
testcase_16 AC 25 ms
5,700 KB
testcase_17 AC 25 ms
5,744 KB
testcase_18 AC 25 ms
5,760 KB
testcase_19 AC 25 ms
5,708 KB
testcase_20 AC 25 ms
5,528 KB
testcase_21 AC 25 ms
5,748 KB
testcase_22 AC 58 ms
8,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Example program
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <vector>

int main()
{
    int n;
    std::cin >> n;
    std::set<std::string> all, cheaters, non_cheaters;
    std::vector<std::string> order;
    for (int i=0;i<n;++i) {
        std::string a,b;
        std::cin >> a >> b;
        all.insert(b);
        cheaters.insert(a);
        order.push_back(b);
    }
    std::set_difference(all.begin(), all.end(), cheaters.begin(), cheaters.end(), std::inserter(non_cheaters, non_cheaters.end()));
    for (const auto& s : order)
    {
        if (non_cheaters.count(s))
            std::cout << s << std::endl;
        non_cheaters.erase(s);
    }
    return 0;
}
0