제출 #146136

#제출 시각아이디문제언어결과실행 시간메모리
146136evpipisTug of War (BOI15_tug)C++11
23 / 100
15 ms2684 KiB
    #include <bits/stdc++.h>
    using namespace std;

    #define fi first
    #define se second
    #define mp make_pair
    #define pb push_back
    typedef pair<int, int> ii;

    const int len = 6e4+4;
    int vis[len];
    vector<ii> adj[len];

    int check(int u){
        vis[u] = 1;

        int ans = 2-adj[u].size();
        for (int j = 0; j < adj[u].size(); j++){
            ii v = adj[u][j];
            if (!vis[v.fi])
                ans += check(v.fi);
        }

        return ans;
    }

    int main(){
        int n, k;
        scanf("%d %d", &n, &k);
        for (int i = 0; i < 2*n; i++){
            int a, b, c;
            scanf("%d %d %d", &a, &b, &c);
            adj[2*a-2].pb(mp(2*b-1, c));
            adj[2*b-1].pb(mp(2*a-2, c));
        }

        for (int i = 1; i <= n; i++)
            if (!vis[2*i-2] && check(2*i-2) != 0){
                printf("NO\n");
                return 0;
            }

        printf("YES\n");
        return 0;
    }

컴파일 시 표준 에러 (stderr) 메시지

tug.cpp: In function 'int check(int)':
tug.cpp:18:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < adj[u].size(); j++){
                         ~~^~~~~~~~~~~~~~~
tug.cpp: In function 'int main()':
tug.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &n, &k);
         ~~~~~^~~~~~~~~~~~~~~~~
tug.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d %d %d", &a, &b, &c);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...