結果

問題 No.3196 Unique Nickname
ユーザー ruase_
提出日時 2025-08-14 20:12:16
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 96,680 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-14 20:12:18
合計ジャッジ時間 1,804 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int n;
	bool t1_flg = false;
	bool t2_flg = false;
	
	cin >> n;
	string a[n][2];

	for(int i = 0; i < n; i++) cin>> a[i][0] >> a[i][1];

	for(int b = 0; b < n ; b++){
		string t1 = a[b][0];
		string t2 = a[b][1];
		for(int i = 0 ; i < n ; i++)
		{
			if(!(b == i)){
				if(t1 == a[i][0] || t1 == a[i][1])
				{
					t1_flg = true;
				}
				if(t2 == a[i][0] || t2 == a[i][1])
				{
					t2_flg = true;
				}
			}
		}
		if (t1_flg && t2_flg)
		{
			break;
		}
		t1_flg = false;
		t2_flg = false;
	}
	
	if (t1_flg && t2_flg)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

}
0