제출 #987586

#제출 시각아이디문제언어결과실행 시간메모리
987586modwweSum Zero (RMI20_sumzero)C++14
100 / 100
712 ms20472 KiB
//#pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC target("avx,avx2,sse,sse2") #pragma GCC optimize("conserve-stack") #include<bits/stdc++.h> //#define int long long #define down cout<<'\n'; #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 "vrtic" #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(); struct ib { long long a; int b; }; struct icd { int a,b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; int n,m,s2,s4,s3,sf,k,r,mid,dem,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,l; int i,s10,s12; int el=29; main() { //#ifndef ONLINE_JUDGE // fin(task),fou(task); //#endif NHP //modwwe // cin>>res; phongbeo(),down checktime } bool cmp(ib a,ib b) { if(a.a==b.a) return a.b<b.b; return a.a<b.a; } int spt[9][400002]; ib *v; int *t; void phongbeo() {cin>> n; v=new ib[n+1]; v[0]={0,0}; for(int i=1;i<=n;i++) { cin>>l; v[i]={v[i-1].a+l,i}; } sort(v,v+1+n,cmp); t=new int[n+2]; for(int i=0;i<=n;i++) t[i]=n+1; for(int i=0;i<=n;i++) { l=i; while(l<n&&v[l+1].a==v[i].a)l++; for (int f = i; f < l; f++){ // out<<v[f].b+1<<" "<<v[f+1].b,down // if(f==l-1) cout<<v[f].a<<" "<<v[f].b,down // if(v[f].b+1==n) cout<<f<<" "<<v[f+1].b,down t[v[f].b + 1] = v[f + 1].b;} i=l; } delete[] v; r=n+1; spt[0][n+1]=r; for(int i=n;i>=0;--i){ // cout<<r<<" "<<t[i],down spt[0][i]=r,r=min(r,t[i]); } delete [] t; for(int i=1;i<=8;i++) for(int j=0;j<=n+1;j++){ spt[i][j]=spt[i-1][spt[i-1][j]]; } cin>>s2; while(s2--) { cin>>l>>r; l--;s3=0; for(int i=8;i>=0;--i) { while(spt[i][l]<=r) { //cout<<i<<" "<<l,down l=spt[i][l]; s3+=(1<<i); } } cout<<s3,down } }

컴파일 시 표준 에러 (stderr) 메시지

sumzero.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...