結果

問題 No.3196 Unique Nickname
ユーザー Leal-0
提出日時 2025-07-11 21:46:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,344 bytes
コンパイル時間 2,195 ms
コンパイル使用メモリ 205,228 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-07-11 21:47:06
合計ジャッジ時間 3,067 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef INCLUDED_MAIN
#define INCLUDED_MAIN

#include __FILE__

int main(void) {
    ll n; cin>>n;
    vector<string> ss;
    rep(i,n) {
        string s,t; cin>>s>>t;
        ss.pb(s);
        ss.pb(t);
    }
    rep(i,n) {
        ll ban1=i*2,ban2=i*2+1;
        bool b1=false,b2=false;
        rep(j,2*n) {
            if(j==ban1 || j==ban2) continue;
            if(ss[ban1]==ss[j]) b1=true;
            if(ss[ban2]==ss[j]) b2=true;
        }
        if(b1&&b2) {
            no();
            return 0;
        }
    }
    yes();
}

/////// library zone ///////
#else
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define srep(i,l,r) for(ll i=l;i<=r;i++)
#define irep(i,r,l) for(ll i=r;i>=l;i--)
using ll = long long;
using ld = long double;
const ll mod=998244353;
#define vout(v) for(auto i :v) cout<<i<<" ";
#define INF 9223300000000000000ll
#define Winf 5e12
#define nl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vl vector<ll>
#define vc vector<char>
#define pb push_back

bool isin(ll i,ll j,ll h,ll w) {
    return (0<=i && i<h && 0<=j && j<w);
}


ll jg(ll p,ll q){
    ld pred=1;
    pred=(q*q*q);
    pred*=p;
    if(pred>2e18) {
    return 2e18;
    }
    return p*q*q*q;
}


ll op(ll a,ll b) {return max(a,b);}
ll e() {return -Winf; }


vector<ll> Erasieve(ll n) {
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false; 

    for (int i=2;i*i<=n;++i) {
        if (is_prime[i]) {
            for (int j=i*i;j<=n;j+=i) is_prime[j] = false;
        }
    }
    vector<ll> primes;
    srep(i,2,n) {
        if (is_prime[i]) primes.push_back(i);
    }

    return primes;
}

template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}

void no() { cout<<"No"<<nl;}
void yes() { cout<<"Yes"<<nl;}
void yn(bool a) {
    cout<<(a ? "Yes":"No")<<nl;
}

ll modpow(ll fl, ll po, ll mode) {  // mode: 0=modなし, 1=modあり
    ll ret=1;
    if (mode) {
        while (po>0) {
            if (po&1) ret=(ret*fl)%mod;
            fl=(fl*fl)%mod;
            po>>=1;
        }
    } else {
        while (po>0) {
            if(po&1) ret*=fl;
            fl*=fl;
            po>>=1;
        }
    }
    return ret;
}
#endif
0