# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1051377 |
2024-08-10T05:34:05 Z |
12345678 |
File Paths (BOI15_fil) |
C++17 |
|
325 ms |
1000 KB |
#include <bits/stdc++.h>
using namespace std;
const int nx=6e3+5;
int n, m, k, sz, pa[nx], dist[nx], w, res[nx];
vector<pair<int, int>> d[nx];
void dfs(int u)
{
//cout<<"dist "<<u<<' '<<dist[u]<<'\n';
for (auto [v, w]:d[u]) dist[v]=dist[u]+w, dfs(v);
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m>>k>>sz;
for (int i=1; i<=n; i++) cin>>pa[i]>>w, d[pa[i]].push_back({i, w+1});
for (int i=n+1; i<=n+m; i++) cin>>pa[i]>>w, d[pa[i]].push_back({i, w+1});
dfs(0);
for (int i=n+1; i<=n+m; i++)
{
if (dist[i]==k) res[i]=1;
set<int> s;
s.insert(0);
int tmp=i;
while (tmp!=0) s.insert(dist[i]-dist[pa[tmp]]), tmp=pa[tmp];
for (int j=0; j<=n; j++) if (s.find(k-dist[j]-sz-1)!=s.end()) res[i]=1;
if (res[i]) cout<<"YES\n";
else cout<<"NO\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
604 KB |
Output is correct |
2 |
Correct |
54 ms |
600 KB |
Output is correct |
3 |
Correct |
40 ms |
604 KB |
Output is correct |
4 |
Correct |
46 ms |
752 KB |
Output is correct |
5 |
Correct |
280 ms |
856 KB |
Output is correct |
6 |
Correct |
292 ms |
856 KB |
Output is correct |
7 |
Correct |
179 ms |
856 KB |
Output is correct |
8 |
Correct |
188 ms |
920 KB |
Output is correct |
9 |
Correct |
46 ms |
812 KB |
Output is correct |
10 |
Correct |
35 ms |
600 KB |
Output is correct |
11 |
Correct |
54 ms |
604 KB |
Output is correct |
12 |
Correct |
325 ms |
1000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |