제출 #992835

#제출 시각아이디문제언어결과실행 시간메모리
992835modwwe별자리 3 (JOI20_constellation3)C++17
0 / 100
2 ms16732 KiB
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2") #include<bits/stdc++.h> //#define int long long //#define ll 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 "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 mod2=998244353; const int mod1=998244353; struct icd { int a,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,f; }; int n,m,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l; int i,s10,s12; int el=29; main() { #ifndef ONLINE_JUDGE //fin(task),fou(task); #endif NHP /// cin>>s1; ///modwwe phongbeo(); } vector<ic> v; int bit[200002]; int st[18][200001]; int lazy[800001]; int t[800001]; bool cmp(ic a,ic b) { return a.a<b.a; } void upd_bit(int x,int y) { for(x; x<=n+1; x+=x&-x) bit[x]=min(bit[x],y); } int get_bit(int x) { int ss=0; for(x; x; x-=x&-x) ss=min(ss,bit[x]); return ss; } int get_rmq(int l,int r) { int k=log2(r-l+1); return max(st[k][l],st[k][r-(1<<k)+1]); } void ff(int x) { for(int i=x*2; i<=x*2+1; i++) t[i]=0, lazy[i]=1; lazy[x]=0; } void upd(int node,int l,int r,int l1,int r1,int c) { if(l>r1||r<l1) return; if(l>=l1&&r<=r1) { t[node]=min(t[node],c); return; } int mid=l+r>>1; if(lazy[node]) ff(node); upd(node<<1,l,mid,l1,r1,c); upd(node<<1|1,mid+1,r,l1,r1,c); t[node]=min(t[node<<1],t[node<<1|1]); } void upd2(int node,int l,int r,int l1,int r1) { if(l>r1||r<l1) return; if(l>=l1&&r<=r1) { lazy[node]=1; t[node]=0; return; } if(lazy[node]) ff(node); int mid=l+r>>1; upd2(node<<1,l,mid,l1,r1); upd2(node<<1|1,mid+1,r,l1,r1); t[node]=min(t[node<<1],t[node<<1|1]); } int gett(int node,int l,int r,int l1,int r1) { if(l>r1||r<l1) return 0; if(l>=l1&&r<=r1)return t[node]; int mid=l+r>>1; if(lazy[node]) ff(node); return min(gett(node<<1,l,mid,l1,r1),gett(node<<1|1,mid+1,r,l1,r1)); } void phongbeo() { cin>>n; for(int i=1; i<=n; i++) cin>>st[0][i]; cin>>m; for(int i=1; i<=m; i++) { cin>>l>>r>>s2; v.pb({l,r,s2}); s6+=s2; } sort(v.begin(),v.end(),cmp); for(int j=1; j<18; j++) for(int i=1; i<=n; i++) st[j][i]=max(st[j-1][i],st[j-1][i+(1<<(j-1))]); s4=1e18; for(int i=0; i<v.size(); i++) { ic x=v[i]; l=1; r=x.a; while(l<=r) { int mid=l+r>>1; if(get_rmq(mid,x.a)>=x.b)l=mid+1; else r=mid-1; } s2=l-1; s3=get_bit(s2); s3=s3-x.c; s5=gett(1,1,n,1,st[0][x.a]); upd_bit(x.a,s3+s5); upd(1,1,n,x.b,x.b,s5-x.c); if(i==v.size()-1) break; if(v[i+1].a!=v[i].a) upd2(1,1,n,1,st[0][x.a]); } cout<<s6+get_bit(n+1); }

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

constellation3.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main()
      | ^~~~
constellation3.cpp: In function 'void upd_bit(int, int)':
constellation3.cpp:66:9: warning: statement has no effect [-Wunused-value]
   66 |     for(x; x<=n+1; x+=x&-x)
      |         ^
constellation3.cpp: In function 'int get_bit(int)':
constellation3.cpp:72:9: warning: statement has no effect [-Wunused-value]
   72 |     for(x; x; x-=x&-x)
      |         ^
constellation3.cpp: In function 'void upd(int, int, int, int, int, int)':
constellation3.cpp:96:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   96 |     int mid=l+r>>1;
      |             ~^~
constellation3.cpp: In function 'void upd2(int, int, int, int, int)':
constellation3.cpp:114:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  114 |     int mid=l+r>>1;
      |             ~^~
constellation3.cpp: In function 'int gett(int, int, int, int, int)':
constellation3.cpp:123:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  123 |     int mid=l+r>>1;
      |             ~^~
constellation3.cpp: In function 'void phongbeo()':
constellation3.cpp:144:8: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
  144 |     s4=1e18;
      |        ^~~~
constellation3.cpp:145:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ic>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  145 |     for(int i=0; i<v.size(); i++)
      |                  ~^~~~~~~~~
constellation3.cpp:152:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  152 |             int mid=l+r>>1;
      |                     ~^~
constellation3.cpp:162:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ic>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  162 |         if(i==v.size()-1) break;
      |            ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...