Submission #776981

#TimeUsernameProblemLanguageResultExecution timeMemory
776981Dan4LifeSequence (APIO23_sequence)C++17
0 / 100
44 ms8388 KiB
#include "sequence.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; template<class T> using Tree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #define sz(a) (int)a.size() #define fi first #define se second #define pb push_back vector<pair<int,int>> v; Tree<pair<int,int>> S; map<int,int> tot; int n; int sequence(int N, vector<int> a) { n = N; int ans = 1; for(int i = 0; i < n; i++){ int j = i; while(i<n-1 and a[i]==a[i+1]) i++; v.pb({a[i],i-j+1}); ans = max(ans, i-j+1); } for(int i = 0; i < sz(v); i++) if(i+2<sz(v) and v[i].fi==v[i+2].fi) ans = max(ans, v[i].se+v[i+2].se); return ans; }
#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...