제출 #1126874

#제출 시각아이디문제언어결과실행 시간메모리
1126874Halym2007Pipes (BOI13_pipes)C++17
0 / 100
6 ms5224 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define sz size() #define ff first #define ss second #define pb push_back #define pii pair <int, int> #define dur exit(0) #define dur1 return(0) const int N = 2e5 + 5; ll n, m, val[N], jog[N]; pii par[N]; vector <pii> v[N]; vector <int> order; void dfs (int x, int p) { for (pii i : v[x]) { if (i.ff == p) continue; dfs (i.ff, x); par[i.ff] = {x, i.ss}; } order.pb (x); } int main () { freopen ("input.txt", "r", stdin); ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; assert (n - 1 == m); for (int i = 1; i <= n; ++i) { cin >> val[i]; } for (int i = 1; i <= m; ++i) { int l, r; cin >> l >> r; v[l].pb ({r, i}); v[r].pb ({l, i}); } dfs (1, -1); // for (int i : order) { // cout << i << " "; // } // return 0; order.pop_back(); for (int i : order) { val[par[i].ff] -= val[i]; jog[par[i].ss] = val[i]; } if (!val[1]) { for (int i = 1; i <= m; ++i) { cout << jog[i] + jog[i] << "\n"; } } else cout << "0"; }

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

pipes.cpp: In function 'int main()':
pipes.cpp:27:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen ("input.txt", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...