# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
668755 |
2022-12-04T21:40:53 Z |
Kahou |
File Paths (BOI15_fil) |
C++14 |
|
0 ms |
0 KB |
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define endl '\n'
#define mk make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 6050, M = 1e6 + 50;
int n, m, h[N], k, s, p[N];
vector<int> adj[N];
bool out[N];
int cnt[M];
vector<int> vc[N];
vector<int> vt[N];
void dfs(int u) {
for (int x:vt[u]) {
cnt[x]++;
}
if (u > n) {
cerr << "OK " << u << endl;
int T = k-h[u];
cerr << T << endl;
for (int d = 1; d*d <= T; d++) {
if (T%d == 0) {
cout << d << ' ' << cnt[d] << endl;
cout << T/d << ' ' << cnt[T/d] << endl;
out[u] = out[u] || (cnt[d] > 0);
out[u] = out[u] || (cnt[T/d] > 0);
}
}
}
for (int v:adj[u]) {
dfs(v);
}
for (int x:vt[u]) {
cnt[x]--;
}
}
void solve() {
cin >> n >> m >> k;
cin >> s;
s++;
vc[0].push_back(0);
p[0] = -1;
for (int u = 1; u <= n+m; u++) {
int l;
cin >> p[u] >> l;
adj[p[u]].push_back(u);
l++;
h[u] = h[p[u]]+l;
vc[u] = vc[p[u]];
if (u <= n) vc[u].push_back(h[u]);
}
for (int u = 0; u <= n; u++) {
int v = u;
while (v >= 0) {
vt[v].push_back(h[u]-h[v]+s);
v = p[v];
}
}
dfs(0);
sort(h, h+n+1);
for (int u = n+1; u <= n+m; u++) {
out[u] = out[u] || (h[u] == k);
for (int x:vc[u]) {
int v = lower_bound(h, h+n+1, k-s-(h[u]-x))-h;
ut[u] = out[u] || (h[v] + s + h[u]-x == k);
}
cout << (out[u]?"YES":"NO") << endl;
}
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
solve();
return 0;
}
Compilation message
fil.cpp: In function 'void solve()':
fil.cpp:77:25: error: 'ut' was not declared in this scope; did you mean 'u'?
77 | ut[u] = out[u] || (h[v] + s + h[u]-x == k);
| ^~
| u