結果

問題 No.1023 Cyclic Tour
ユーザー ゆきのんゆきのん
提出日時 2020-04-15 18:27:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,360 bytes
コンパイル時間 1,387 ms
コンパイル使用メモリ 167,548 KB
実行使用メモリ 17,056 KB
最終ジャッジ日時 2024-04-09 18:55:43
合計ジャッジ時間 5,740 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
13,856 KB
testcase_01 WA -
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

vector<int> G[1<<17];
vector<int> vis(1<<17,0);

bool dfs(int u,int v,int s){
    if(vis[u] == s + 1){
        if(u == v) return false;
        else return true;
    }
    vis[u] = s + 1;
    for(auto g:G[u]){
        if(g == v) continue;
        if(dfs(g, u, s)) return true;
    }
    return false;
}


int main(){
    int n,m;cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x,y,c;cin >> x >> y >> c;
        x--,y--;
        if(c == 1){
            G[x].pb(y);
            G[y].pb(x);
        }
        else{
            G[x].pb(y);
        }
    }
    bool ans = false;
    for (int i = 0; i < n; i++) {
        ans |= dfs(i,i,i);
    }
    if(ans) puts("Yes");
    else puts("No");
    return 0;
}

    
0