Submission #668663

#TimeUsernameProblemLanguageResultExecution timeMemory
668663KahouFile Paths (BOI15_fil)C++14
33 / 100
164 ms37204 KiB
#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; int n, m, h[N], k, s; vector<int> vc[N]; void solve() { cin >> n >> m >> k; cin >> s; s++; vc[0].push_back(0); for (int u = 1; u <= n+m; u++) { int p, l; cin >> p >> l; l++; h[u] = h[p]+l; vc[u] = vc[p]; if (u <= n) vc[u].push_back(h[u]); } sort(h, h+n+1); for (int u = n+1; u <= n+m; u++) { bool flg = (h[u] == k); for (int x:vc[u]) { int v = lower_bound(h, h+n+1, k-s-(h[u]-x))-h; if (h[v] + s + h[u]-x == k) flg = 1; } cout << (flg? "YES":"NO") << endl; } } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...