Submission #1047750

#TimeUsernameProblemLanguageResultExecution timeMemory
1047750modwweSequence (APIO23_sequence)C++17
Compilation error
0 ms0 KiB
//https://www.instagram.com/_modwwe/ #pragma GCC optimize("Ofast,unroll-loops") #include<bits/stdc++.h> //#define int long long //#define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".out","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; void phongbeo(); const int inf=1e9; const int mod2=1e9+7; const int mod1=998244353; struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c,d,e; }; int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid; int i,s10,s12; int kk; int el=29; main() { #ifndef ONLINE_JUDGE fin(task),fou(task); #endif NHP /// cin>>s1; // modwwe phongbeo(); } ib mer(ib a,ib b) { return {max(a.a,b.a),min(a.b,b.b)}; } struct IT { ib t[2000005]; int t2[2000005]; int t3[2000005]; void build(int node,int l,int r) { if(l==r) { t[node]= {n-l+1,n-l+1}; return; } int mid=l+r>>1; build(node<<1,l,mid); build(node<<1|1,mid+1,r); t[node]=mer(t[node<<1],t[node<<1|1]); } void ff(int x) { for(int i=x*2; i<=x*2+1; i++) t[i].a+=t2[x], t[i].b+=t2[x], t2[i]+=t2[x], t3[i]+=t3[x], t[i].a+=t3[x], t[i].b-=t3[x]; t2[x]=0; t3[x]=0; } void upd(int node,int l,int r,int l1,int r1,int x) { if(l>r1||r<l1) return; if(l>=l1&&r<=r1) { t[node].a+=x; t[node].b+=x; t2[node]+=x; return; } if(t2[node]!=0||t3[node]!=0) ff(node); int mid=l+r>>1; upd(node<<1,l,mid,l1,r1,x); upd(node<<1|1,mid+1,r,l1,r1,x); t[node]=mer(t[node<<1],t[node<<1|1]); } void upd2(int node,int l,int r,int l1,int r1,int x) { if(l>r1||r<l1) return; if(l>=l1&&r<=r1) { t[node].a+=x; t[node].b-=x; t3[node]+=x; return; } if(t2[node]!=0||t3[node]!=0) ff(node); int mid=l+r>>1; upd2(node<<1,l,mid,l1,r1,x); upd2(node<<1|1,mid+1,r,l1,r1,x); t[node]=mer(t[node<<1],t[node<<1|1]); } ib get(int node,int l,int r,int l1,int r1) { if(l>r1||r<l1) return {-inf,inf}; if(l>=l1&&r<=r1) return t[node]; if(t2[node]!=0||t3[node]!=0) ff(node); int mid=l+r>>1; return mer(get(node<<1,l,mid,l1,r1),get(node<<1|1,mid+1,r,l1,r1)); } } st; vector<int> v[500002]; int sequence(int x,vector<int>_a) { n=x; for(int i=0; i<x; i++) v[_a[i]].pb(i+1); st.build(1,1,n+1); s4=0; for(int i=1; i<=n; i++) { v[i].pb(n+1); dem=0; for(int j=0; j<v[i].size()-1; j++) { int x=v[i][j]; int x2=v[i][j+1]; st.upd(1,1,n+1,1,x,-1); ib xx=st.get(1,1,n+1,x,x2); st.upd2(1,1,n+1,1,x,1); l=1; r=x; while(l<=r) { int mid=l+r>>1; ib xc=st.get(1,1,n+1,1,mid); if(xc.a-xx.b>=0&&xc.b-xx.a<=0)r=mid-1; else l=mid+1; } dem++; s2=lower_bound(v[i].begin(),v[i].end(),r+1)-v[i].begin(); s4=max(s4,dem-s2); } for(int j=0; j<v[i].size()-1; j++) { x=v[i][j]; st.upd(1,1,n+1,1,x,-1); st.upd2(1,1,n+1,1,x,-1); } } return s4; } void phongbeo() { cin>>n; vector<int> a(n); for(int i=0; i<n; i++) cin>>a[i]; cout<<sequence(n,a); }

Compilation message (stderr)

sequence.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main()
      | ^~~~
sequence.cpp: In member function 'void IT::build(int, int, int)':
sequence.cpp:77:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   77 |         int mid=l+r>>1;
      |                 ~^~
sequence.cpp: In member function 'void IT::upd(int, int, int, int, int, int)':
sequence.cpp:106:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  106 |         int mid=l+r>>1;
      |                 ~^~
sequence.cpp: In member function 'void IT::upd2(int, int, int, int, int, int)':
sequence.cpp:122:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  122 |         int mid=l+r>>1;
      |                 ~^~
sequence.cpp: In member function 'ib IT::get(int, int, int, int, int)':
sequence.cpp:132:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  132 |         int mid=l+r>>1;
      |                 ~^~
sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:148:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  148 |         for(int j=0; j<v[i].size()-1; j++)
      |                      ~^~~~~~~~~~~~~~
sequence.cpp:159:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  159 |                 int mid=l+r>>1;
      |                         ~^~
sequence.cpp:169:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  169 |         for(int j=0; j<v[i].size()-1; j++)
      |                      ~^~~~~~~~~~~~~~
sequence.cpp: In function 'int main()':
sequence.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
sequence.cpp:54:5: note: in expansion of macro 'fin'
   54 |     fin(task),fou(task);
      |     ^~~
sequence.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
sequence.cpp:54:15: note: in expansion of macro 'fou'
   54 |     fin(task),fou(task);
      |               ^~~
/usr/bin/ld: /tmp/cc9MCVlY.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQ5LYMY.o:sequence.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status