# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995304 | 2024-06-08T19:29:44 Z | idk__ | September (APIO24_september) | C++17 | 9 ms | 19800 KB |
#include "september.h" #include <bits/stdc++.h> using namespace std; int vis[200055]; vector<int>adj[200055]; vector<int>idx[200055]; bool flag = false; int pos[20055]; int dfs(int i ){ int curr = pos[i]; vis[i]=1; for(auto j : adj[i]){ if(!vis[j]){ curr = max(curr, dfs(j)); } } return curr; } int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { //return 5; memset(vis, 0, N); memset(idx, 0, N); memset(pos, 0, N); for(int i = 0;i < N; i++)if(adj[i].size())adj[i].clear(); for(int i = 1;i < F.size(); i++){ //adj[i].push_back(F[i]); adj[F[i]].push_back(i); } for(auto i : S[0]){ pos[S[0][i]] = i; } vector<int>vec; for(auto i : S[0])vec.push_back(i); int cnt = 0; for(int i = 0;i < vec.size(); i++){ int y = 0; if(vec[i]==1)flag = true; int R_ind = dfs(vec[i]); if(vec[i]==1){ //cout << R_ind << " "; } for(int j = i+1; j<=R_ind; j++){ R_ind = max(R_ind, dfs(vec[j])); } i = max(i, R_ind); cnt++; } return cnt; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 9816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 9816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 9 ms | 19800 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 9816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 9 ms | 19800 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 9816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 9 ms | 19800 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 9816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 9 ms | 19800 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 9816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |