/******************************************************
| '_ \ / _` |/ __| '_ ` _ \ / _` | '_ \
| |_) | (_| | (__| | | | | | (_| | | | |
| .__/ \__,_|\___|_| |_| |_|\__,_|_| |_|
|_|
__| |____________________________________________
,--. ,--. ,--. ,--.
|oo | _ \ `. | oo | | oo|
o o|~~ |(_) / ; | ~~ | | ~~|o o o o o
|/\/\| '._,' |/\/\| |/\/\|
__________________ ____________________________
******************************************************/
#include <bits/stdc++.h>
#define db(x) cerr << #x << ": " << x << endl
#define print cerr << "Ah shit, here we go again" << endl
#define int long long int
#define vii vector<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define ff first
#define ss second
#define mp make_pair
#define mod 1000000007
using namespace std;
const int maxn = 100000 + 5;
int n, m, k;
struct mive {
int v, d, w;
};
int st[maxn], fn[maxn], timer = 1;
vector<int> adj[maxn];
vector<mive> f;
void dfs(int v, int mpar = 0) {
st[v] = timer++;
for(auto u : adj[v]){
if(u != mpar){
dfs(u, v);
}
}
fn[v] = timer++;
}
bool zird(int u, int v){
return st[u] >= st[v] && fn[u] <= fn[v];
}
bool cmp(mive a ,mive b){
return a.v < b.v;
}
void solve(){
cin >> n >> m >> k;
for(int i =1; i<=n; i++) adj[i].clear();
f.clear();
timer =1;
for(int i =2; i<=n; i++){
int x;
cin >> x;
adj[x].push_back(i);
adj[i].push_back(x);
}
for(int i=0; i<m; i++){
int x, y, z;
cin >> x >> y >> z;
f.push_back({x, y, z});
}
sort(f.begin(), f.end(), cmp);
vector<int> dp(m, 0);
dp[0] = 1;
for(int i=1; i<m; i++){
dp[i] = dp[i-1];
for(int j=0; j<i; j++){
if(f[j].d <= f[i].d){
dp[i] = max(dp[i], dp[j] +1);
}
}
}
cout << (m >0 ? *max_element(dp.begin(), dp.end()) : 0) << endl;
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t =1;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
801 ms |
7500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2068 ms |
10192 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
3408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |