結果
| 問題 |
No.3196 Unique Nickname
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-11 21:39:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 2,837 bytes |
| コンパイル時間 | 958 ms |
| コンパイル使用メモリ | 117,312 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2025-07-11 21:39:14 |
| 合計ジャッジ時間 | 1,525 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <queue>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <iterator>
#include <unordered_map>
#include <stack>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <unordered_set>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
const ll MOD2 = 1'000'000'007;
class SegTree {
public:
vector<ll> dat;
ll siz = 1;
SegTree(ll n) {
while (siz < n) siz *= 2;
dat.resize(2 * siz, -LLONG_MAX);
}
void update(int id, ll x) {
id += siz;
dat[id] = x;
while (id != 0) {
id /= 2;
dat[id] = max(dat[2 * id], dat[2 * id + 1]);
}
}
ll getval(int id) {
return dat[id + siz];
}
ll getmax(ll L, ll R, ll a, ll b, ll u) {
if (b <= L || R <= a) return -LLONG_MAX / 2;
if (L <= a && b <= R) return dat[u];
ll m = (a + b) / 2;
return max(getmax(L, R, a, m, 2 * u),
getmax(L, R, m, b, 2 * u + 1));
}
};
class UnionFind {
public:
vector<int> siz, par;
UnionFind(int n) {
siz.assign(n, 1);
par.assign(n, -1);
}
int root(int x) {
return par[x] == -1 ? x : par[x] = root(par[x]);
}
void unite(int x, int y) {
int rx = root(x), ry = root(y);
if (rx == ry) return;
if (siz[rx] < siz[ry]) {
par[rx] = ry;
siz[ry] += siz[rx];
}
else {
par[ry] = rx;
siz[rx] += siz[ry];
}
}
bool same(int x, int y) {
return root(x) == root(y);
}
};
long long modinv(long long a, long long m) {
long long b = m, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
u %= m; if (u < 0) u += m;
return u;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
int dx[] = { 1, 0, -1, 0 }, dy[] = { 0, 1, 0, -1 };
//ios::sync_with_stdio(false);
//cin.tie(nullptr);
int main() {
int N; cin >> N;
vector<pair<string, string>> name(N);
for (int i = 0; i < N; i++)cin >> name[i].first >> name[i].second;
bool ans = true;
for (int i = 0; i < N; i++) {
bool u = true, v = true;
for (int j = 0; j < N; j++) {
if (i == j)continue;
if (name[i].first == name[j].first || name[i].first == name[j].second)u = false;
if (name[i].second == name[j].first || name[i].second == name[j].second)v = false;
}
if (!u && !v)ans = false;
}
cout << (ans ? "Yes" : "No") << endl;
}