結果
問題 |
No.3196 Unique Nickname
|
ユーザー |
|
提出日時 | 2025-07-21 16:18:38 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,810 bytes |
コンパイル時間 | 6,255 ms |
コンパイル使用メモリ | 335,492 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-21 16:18:46 |
合計ジャッジ時間 | 6,758 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif #ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif using ll = long long; using ld = long double; using P = pair<ll,ll>; template<class T> using pq = priority_queue<T>; template<class T> using pq_g = priority_queue<T, vector<T>, greater<T>>; #define out(x) cout<<x<<'\n' #define dump(x) cerr<<#x<<" = "<<x<<'\n' #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define OVERLOAD_REP(_1,_2,_3,name,...) name #define REP1(i,n) for (auto i = std::decay_t<decltype(n)>{}; (i) != (n); ++(i)) #define REP2(i, l, r) for (auto i = (l); (i) != (r); ++(i)) #define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__) template<class T> inline bool chmin(T& a, T b) {if(a > b){a = b; return true;} else {return false;}}; template<class T> inline bool chmax(T& a, T b) {if(a < b){a = b; return true;} else {return false;}}; const ll INF=(1LL<<60); const ll mod=998244353; using Graph = vector<vector<ll>>; using Network = vector<vector<pair<ll,ll>>>; using Grid = vector<string>; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int dx2[8] = {1, 1, 1, 0, 0, -1, -1, -1}; const int dy2[8] = {1, 0, -1, 1, -1, 1, 0, -1}; void solve() { ll N;cin>>N; vector<string> S(N), T(N); rep(i, N) cin >> S[i] >> T[i]; map<string, int> cnt; rep(i, N) { cnt[S[i]]++; cnt[T[i]]++; } rep(i, N) { cnt[S[i]]--; cnt[T[i]]--; if (cnt[S[i]] > 0 && cnt[T[i]] > 0) { out("No"); return; } cnt[S[i]]++; cnt[T[i]]++; } out("Yes"); } int main() { cin.tie(0); ios_base::sync_with_stdio(false); solve(); return 0; }