# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40353 | krauch | 동기화 (JOI13_synchronization) | C++14 | 161 ms | 25724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |