Submission #632131

#TimeUsernameProblemLanguageResultExecution timeMemory
632131MohamedFaresNebiliTraining (IOI07_training)C++14
7 / 100
2 ms544 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define ff first #define ss second #define pb push_back #define all(x) (x).begin(), (x).end() #define lb lower_bound #define int ll int N, M, D[1001]; vector<int> adj[1001]; vector<array<int, 3>> G; void dfs(int v, int p) { D[v] = D[p] + 1; for(auto u : adj[v]) { if(u == p) continue; dfs(u, v); } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> M; for(int l = 0; l < M; l++) { int U, V, C; cin >> U >> V >> C; if(C == 0) adj[U].push_back(V), adj[V].push_back(U); if(C >= 1) G.push_back({U, V, C}); } int res = 0, src = 0; for(int l = 1; l <= N; l++) { if(adj[l].size() == 1) src = l; } D[src] = -1; dfs(src, src); for(auto e : G) { int U = e[0], V = e[1], C = e[2]; if(abs(D[V] - D[U]) & 1) res += C; } cout << res << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...