제출 #40353

#제출 시각아이디문제언어결과실행 시간메모리
40353krauch동기화 (JOI13_synchronization)C++14
0 / 100
161 ms25724 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair < int, int > PII; #define F first #define S second #define mkp make_pair #define eb emplace_back #define all(a) a.begin(), a.end() #define sz(a) (int)a.size() #define forn(x, a, b) for (int x = a; x <= b; ++x) #define for1(x, a, b) for (int x = a; x >= b; --x) const ll ool = 1e18 + 9; const int N = 3e5 + 3, oo = 1e9 + 9; int n, m, Q; vector < int > vec[N]; vector < PII > g[N]; int dfs(int v, int par, int X) { int res = 1; for (auto it : g[v]) { int to = it.F; if (to == par) continue; int pos = lower_bound(all(vec[it.S]), X) - vec[it.S].begin() - 1; if (pos < 0) continue; res += dfs(to, v, vec[it.S][pos]); } return res; } int main() { #ifdef krauch freopen("input.txt", "r", stdin); #endif scanf("%d%d%d", &n, &m, &Q); forn(i, 1, n - 1) { int x, y; scanf("%d%d", &x, &y); g[x].eb(y, i); g[y].eb(x, i); } forn(i, 1, m) { int x; scanf("%d", &x); vec[x].eb(i); } forn(i, 1, Q) { int x; scanf("%d", &x); cout << dfs(x, 0, m + 1) << "\n"; } return 0; }

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

synchronization.cpp: In function 'int main()':
synchronization.cpp:42:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &Q);
                                ^
synchronization.cpp:45:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x, &y);
                              ^
synchronization.cpp:52:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
                        ^
synchronization.cpp:58:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
                        ^
#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...