結果

問題 No.938 賢人を探せ
ユーザー rogi52rogi52
提出日時 2022-10-07 12:26:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 2,775 ms
コンパイル使用メモリ 226,480 KB
実行使用メモリ 8,396 KB
最終ジャッジ日時 2023-09-02 13:16:52
合計ジャッジ時間 4,266 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
8,396 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 19 ms
6,296 KB
testcase_09 AC 19 ms
5,476 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 31 ms
6,808 KB
testcase_12 AC 18 ms
5,228 KB
testcase_13 AC 18 ms
5,352 KB
testcase_14 AC 18 ms
5,216 KB
testcase_15 AC 18 ms
5,216 KB
testcase_16 AC 17 ms
5,460 KB
testcase_17 AC 18 ms
5,312 KB
testcase_18 AC 18 ms
5,272 KB
testcase_19 AC 18 ms
5,324 KB
testcase_20 AC 18 ms
5,368 KB
testcase_21 AC 18 ms
5,224 KB
testcase_22 AC 32 ms
8,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N; cin >> N;
    map<string,int> id;
    set<string> st;
    vector<string> ng(N);
    int ID = 0;
    rep(i,N) {
        string a,b; cin >> a >> b;
        if(!id.count(b)) id[b] = ID++;
        ng[i] = a;
        st.insert(b);
    }

    for(string &a : ng) st.erase(a);
    vector<pair<int,string>> ans;
    for(string s : st) ans.push_back({id[s], s});
    sort(ans.begin(), ans.end());
    for(auto [_, s] : ans) cout << s << "\n";
}
0