Submission #146135

#TimeUsernameProblemLanguageResultExecution timeMemory
146135evpipisTug of War (BOI15_tug)C++11
0 / 100
16 ms2936 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 (check(2*i-2)){ printf("NO\n"); return 0; } printf("YES\n"); return 0; }

Compilation message (stderr)

tug.cpp: In function 'int check(int)':
tug.cpp:18:23: 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:10: 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:14: 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...