제출 #588736

#제출 시각아이디문제언어결과실행 시간메모리
588736Loki_NguyenPower Plant (JOI20_power)C++14
0 / 100
4 ms7380 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define task "test" #define pll pair<ll, ll> #define pii pair<ll, pll> #define fi first #define se second #define ull unsigned long long using namespace std; const ll mod = 1e15 + 7; const ll N = 3e5 + 5; const ll M = 1e6 + 5; vector<ll> adj[N]; vector<ll> kq; int n, m, t, k, b[N], lab[N], a[N], ans, tong, d[N]; string s; pll p[N]; void sol() { cin >> n; for (int i = 1; i < n; i++) { int x, y; cin >> x >> y; adj[x].pb(y); adj[y].pb(x); ++d[x]; ++d[y]; } cin >> s; queue<int> q; for(int i = 1; i <= n; i ++)if(d[i] == 1)q.push(i); while(!q.empty()) { int u = q.front(); q.pop(); if(s[u-1] == '1') { ++ans; continue; } for(int v: adj[u]) { --d[v]; if(d[v] == 1)q.push(v); } } cout << ans; } int main() { if (fopen(task ".in", "r")) { freopen(task ".in", "r", stdin); freopen(task ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ntest = 1; // cin >> ntest; while (ntest-- > 0) sol(); }

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

power.cpp: In function 'int main()':
power.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen(task ".in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
power.cpp:56:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         freopen(task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...