Submission #952364

#TimeUsernameProblemLanguageResultExecution timeMemory
952364MinbaevMagic Tree (CEOI19_magictree)C++17
0 / 100
23 ms4552 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define f first #define int long long #define s second #define pii pair<int,int> template<class T>bool umax(T &a,T b){if(a<b){a=b;return true;}return false;} template<class T>bool umin(T &a,T b){if(b<a){a=b;return true;}return false;} typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int N = 1e6 + 5; const int inf = 1e17 + 7; const int mod = 1e9 + 7; int n,m,k; vector<int>ans,a; void solve(){ cin >> n >> m >> k; for(int i = 2;i<=n;i++){ int b; cin >> b; } vector<int>g(n+1); for(int i = 0;i<m;i++){ int b,c,d; cin >> b >> c >> d; g[b] = c; } for(int i = 1;i<=m;i++){ if(g[i] == 0)continue; a.pb(g[i]); } for(int i = 0;i<n;i++){ auto it = lower_bound(all(ans),a[i]); if(it != ans.end()){ *it = a[i]; } else ans.pb(a[i]); } cout << ans.size()<<"\n"; //~ for(auto to:ans)cout << -to << " "; } /* 6 6 2 1 2 3 4 5 1 1 1 2 2 2 3 3 1 4 4 2 5 5 2 6 6 1 // Success consists of going from failure to failure without loss of enthusiasm // Problems means that you are trying // Soberis dolboyeb */ signed main() { // freopen("seq.in", "r", stdin); // freopen("seq.out", "w", stdout); ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); int tt=1;//cin>>tt; while(tt--)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...