結果

問題 No.3196 Unique Nickname
ユーザー pillow
提出日時 2025-07-16 14:47:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 854 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 201,568 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-16 14:47:57
合計ジャッジ時間 3,096 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<vector<string>> temp(n, vector<string>());
    rep(i, n) {
        string s, t;
        cin >> s >> t;
        temp[i].push_back(s);
        temp[i].push_back(t);
    }
    rep(i, n) {
        bool ok_s = true;
        bool ok_t = true;
        rep(j, n) {
            if (i == j) continue;
            if (temp[i][0] == temp[j][0] || temp[i][0] == temp[j][1])
                ok_s = false;
            if (temp[i][1] == temp[j][0] || temp[i][1] == temp[j][1])
                ok_t = false;
        }
        if (!ok_s && !ok_t) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
0