結果

問題 No.3196 Unique Nickname
ユーザー eve__fuyuki
提出日時 2025-07-12 19:48:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 194,940 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-07-12 19:49:00
合計ジャッジ時間 2,544 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void fast_io() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
}

int main() {
	fast_io();
	int n;
	cin >> n;
	vector<string> s(n), t(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i];
	}
	for (int i = 0; i < n; i++) {
		bool s_ok = true, t_ok = true;
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			if (s[i] == s[j] || s[i] == t[j]) s_ok = false;
			if (t[i] == t[j] || t[i] == s[j]) t_ok = false;

			if (!s_ok && !t_ok) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}
0