Submission #668663

# Submission time Handle Problem Language Result Execution time Memory
668663 2022-12-04T11:14:18 Z Kahou File Paths (BOI15_fil) C++14
33 / 100
164 ms 37204 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;
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 time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 141 ms 35980 KB Output is correct
6 Correct 150 ms 35836 KB Output is correct
7 Correct 73 ms 21872 KB Output is correct
8 Correct 73 ms 21908 KB Output is correct
9 Correct 4 ms 816 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 7 ms 1620 KB Output is correct
12 Correct 164 ms 37204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -