# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
367506 | 2021-02-17T14:26:08 Z | cpp219 | Uzastopni (COCI15_uzastopni) | C++14 | 343 ms | 65540 KB |
#include <bits/stdc++.h> #define ll int #define ld long double #define fs first #define sc second using namespace std; const ll N = 1e4 + 9; const ll inf = 1e9 + 7; typedef pair<int,int> LL; vector<ll> g[N]; ll n,v[N],x,y; bitset<110> flag[N][110]; vector<LL> s[N]; void DFS(ll u){ for (auto i : g[u]) DFS(i); vector<ll> q[N]; for (auto i : g[u]){ for (auto j : s[i]) q[j.fs].push_back(j.sc); } for (ll l = 109;l > 0;l--){ if (l == v[u]){ flag[u][l] |= flag[u][l + 1]; flag[u][l].set(l); } else{ for (auto i : q[l]){ if (l > v[u] || i < v[u]){ flag[u][l] |= flag[u][i + 1]; flag[u][l].set(i); } } } for (ll i = 100;i >= l;i--) if (flag[u][l][i] == 1 && l <= v[u] && i >= v[u]) s[u].push_back({l,i}); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n; for (ll i = 1;i <= n;i++) cin>>v[i]; for (ll i = 1;i < n;i++) cin>>x>>y,g[x].push_back(y); DFS(1); cout<<s[1].size(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2796 KB | Output is correct |
2 | Correct | 4 ms | 3052 KB | Output is correct |
3 | Correct | 5 ms | 3308 KB | Output is correct |
4 | Correct | 4 ms | 3052 KB | Output is correct |
5 | Correct | 6 ms | 3308 KB | Output is correct |
6 | Correct | 13 ms | 17516 KB | Output is correct |
7 | Correct | 13 ms | 17644 KB | Output is correct |
8 | Correct | 13 ms | 17644 KB | Output is correct |
9 | Correct | 5 ms | 2668 KB | Output is correct |
10 | Correct | 6 ms | 2668 KB | Output is correct |
11 | Correct | 343 ms | 23404 KB | Output is correct |
12 | Correct | 332 ms | 23788 KB | Output is correct |
13 | Correct | 332 ms | 24044 KB | Output is correct |
14 | Runtime error | 51 ms | 65540 KB | Execution killed with signal 9 |
15 | Runtime error | 50 ms | 65540 KB | Execution killed with signal 9 |
16 | Runtime error | 50 ms | 65540 KB | Execution killed with signal 9 |
17 | Correct | 335 ms | 23788 KB | Output is correct |
18 | Correct | 334 ms | 23916 KB | Output is correct |
19 | Correct | 329 ms | 23532 KB | Output is correct |
20 | Correct | 329 ms | 23532 KB | Output is correct |