結果
問題 |
No.938 賢人を探せ
|
ユーザー |
![]() |
提出日時 | 2020-08-11 20:31:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 925 bytes |
コンパイル時間 | 2,255 ms |
コンパイル使用メモリ | 186,724 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-14 12:00:26 |
合計ジャッジ時間 | 3,046 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; typedef pair<string, int> vsi; auto compare = [](const vsi& x, const vsi& y) { return x.second > y.second; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<string> va(n); unordered_map<string, int> m; for (int i = 0; i < n; ++i) { string b; cin >> va[i] >> b; if (!m.count(b)) m[b] = i; } priority_queue<vsi, vector<vsi>, decltype(compare)> que{ compare }; for (int i = 0; i < n; ++i) { auto it = m.find(va[i]); if (it != m.end()) m.erase(it); } for (const auto& im : m) { vsi elm{ im.first, im.second }; que.push(elm); } while (!que.empty()) { vsi elem = que.top(); cout << elem.first << "\n"; que.pop(); } return 0; }