結果

問題 No.3196 Unique Nickname
ユーザー Nauclhlt🪷
提出日時 2025-07-03 20:01:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,030 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 206,080 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-10 14:32:26
合計ジャッジ時間 2,581 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

void validateLowerString(string& s)
{
    for (int i = 0; i < s.size(); i++)
    {
        assert(islower(s[i]));
    }
}

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<string> S(N);
    vector<string> T(N);

    map<string, int> count;

    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
        cin >> T[i];
        if (count.find(S[i]) != count.end()) count[S[i]]++;
        else count[S[i]] = 1;
        if (count.find(T[i]) != count.end()) count[T[i]]++;
        else count[T[i]] = 1;
        assert(S[i] != T[i]);
        assert(1 <= S[i].size() && S[i].size() <= 15);
        assert(1 <= T[i].size() && T[i].size() <= 15);
        validateLowerString(S[i]);
        validateLowerString(T[i]);
    }

    bool ok = true;
    for (int i = 0; i < N; i++)
    {
        ok &= (count[S[i]] == 1 || count[T[i]] == 1);
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0