結果

問題 No.3508 OR Mapping
コンテスト
ユーザー AK_Mi
提出日時 2026-04-18 17:02:15
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,102 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,884 ms
コンパイル使用メモリ 346,164 KB
実行使用メモリ 66,048 KB
最終ジャッジ日時 2026-04-18 17:02:41
合計ジャッジ時間 11,683 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using mint = modint998244353;
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    ll n,m,k;
    cin >> n >> m >> k;

    ll u,v;
    vector<vector<ll>> pass(n,vector<ll>(0));
    for(ll i = 0; i < m; i++){
        cin >> u >> v;
        u--;
        v--;
        pass[u].push_back(v);
    }

    vector<vector<bool>> come(n,vector<bool>(2,0));
    queue<pair<ll,ll>> bfs;
    bfs.push({0,0});
    come[0][0] = 1;
    while(!bfs.empty()){
        ll x = bfs.front().first;
        ll p = bfs.front().second;
        bfs.pop();

        for(ll i : pass[x]){
            ll np = p * -1 + 1;
            if(come[i][np])continue;
            come[i][np] = 1;
            bfs.push({i,np});
        }
    }

    bool ans = 1;
    for(ll i = 1; i < n; i++){
        if(!come[i][0] && !come[i][1])ans = 0;
    }
    if(!come[0][1])ans = 0;

    if(ans)cout << "Yes" << '\n';
    else cout << "No" << '\n';

}
0