結果
問題 | No.938 賢人を探せ |
ユーザー |
![]() |
提出日時 | 2019-12-01 01:30:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 1,346 bytes |
コンパイル時間 | 1,718 ms |
コンパイル使用メモリ | 178,700 KB |
実行使用メモリ | 7,680 KB |
最終ジャッジ日時 | 2024-12-14 11:42:00 |
合計ジャッジ時間 | 2,945 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; #define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0) #define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0) struct UnionFind { private: vector<int> par,depth; public: UnionFind (int n) { par.resize(n); depth = vector<int>(n,0); for (int i = 0;i < n;++i) par[i] = i; } int find(int x) { if (par[x] == x) return x; else return par[x] = find(par[x]); } void unite(int x,int y) { x = find(x); y = find(y); if (x == y) return; par[y] = x; if (depth[x] == depth[y]) depth[x]++; else depth[x] = max(depth[x],depth[y]); } bool same(int x,int y) { return find(x) == find(y); } }; int main() { int n,m; cin >> n; vector<string> a(n),b(n); map<string,int> mp; for (int i = 0;i < n;++i) cin >> a[i] >> b[i]; for (int i = 0;i < n;++i) mp[a[i]]++; for (int i = 0;i < n;++i) if (mp[b[i]] == 0) { cout << b[i] << "\n"; mp[b[i]]++; } }