| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 218079 | dolphingarlic | File Paths (BOI15_fil) | C++14 | 14 ms | 6016 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
int n, m, k, s;
vector<pair<int, int>> graph[6001];
bitset<6001> subtree[6001];
int to_root[6001];
bool can[1000001];
void get_subtree(int node = 0) {
for (pair<int, int> i : graph[node]) {
to_root[i.first] = to_root[node] + i.second;
get_subtree(i.first);
subtree[node] |= subtree[i.first];
}
}
bool reachable(int leaf, int node = 0) {
if (to_root[leaf] > k) {
vector<int> ancestors;
FOR(i, 0, n + 1) if (subtree[i][leaf]) ancestors.push_back(i);
int lptr = 0;
FOR(rptr, 1, ancestors.size()) {
while (to_root[lptr] + s + to_root[leaf] - to_root[rptr] < k) lptr++;
if (to_root[lptr] + s + to_root[leaf] - to_root[rptr] == k) return true;
}
return false;
} else return can[k - to_root[leaf]];
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k >> s;
FOR(i, 1, n + m + 1) {
subtree[i][i] = 1;
int p, l;
cin >> p >> l;
graph[p].push_back({i, l});
}
get_subtree();
can[0] = true;
FOR(i, 0, n + 1) FOR(j, i, n + 1) if (subtree[i][j]) {
int period = s + to_root[j] - to_root[i];
if (can[period]) continue;
for (int x = period; x <= k; x += period) can[x] = true;
}
FOR(i, n, n + m) {
if (reachable(i)) cout << "YES\n";
else cout << "NO\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... | ||||
