제출 #1155277

#제출 시각아이디문제언어결과실행 시간메모리
1155277modwwe송신탑 (IOI22_towers)C++20
56 / 100
4041 ms9452 KiB
//#include "gap.h" //#include "mushrooms.h" //#include "prize.h" #include "towers.h" #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 modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task2 "ftree" #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".ans","w",stdout) #define pb push_back #define mask(k) (1<<k) #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l,int r) { return uniform_int_distribution<int>(l,r)(rd); } void phongbeo(); const int inf = 1e16; const ll mod2 = 1e9+7; const ll base=67; int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, mid, l2, r2, center; int i, s10, s12,k1,k2,k3,s11,lim,w,l,r ; int kk; int t; int el = 19;/* main() { if(fopen(task2".inp","r")) { fin(task2); fou(task2); } if(fopen(task".inp","r")) { fin(task); fou(task); } ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); /// cin>>s1; //int t;cin>>t; while(t--) phongbeo(); checktime }*/ int a[100001]; int Left[100002]; int Right[100002]; int st[17][100002]; vector<int> h; void init(int N,vector<int> h) { n=N; for(int i=0; i<n; i++) a[i+1]=h[i]; } int last=-1; void build(int x) { last=x; vector<int> v; for(int i=1; i<=n; i++) Left[i]=Right[i]=n+1; for(int i=n; i>=1; --i) { while(!v.empty()&&a[i]>a[v.back()])v.pop_back(); l=0; r=v.size()-1; while(l<=r) { int mid=l+r>>1; if(a[v[mid]]-x>=a[i]) { l=mid+1; Right[i]=v[mid]; } else { r=mid-1; } } v.pb(i); } v.clear(); for(int i=n; i>=1; --i) { while(!v.empty()&&a[i]<a[v.back()])v.pop_back(); l=0; r=v.size()-1; while(l<=r) { int mid=l+r>>1; if(a[i]-x>=a[v[mid]]) { l=mid+1; Left[i]=v[mid]; } else { r=mid-1; } } v.pb(i); } for(int i=n-1;i>=1;--i) Left[i]=min(Left[i],Left[i+1]), Right[i]=min(Right[i],Right[i+1]); for(int i=1; i<=n; i++) { if(Right[i]==n+1) st[0][i]=n+1; else { st[0][i]=Left[Right[i]]; } } for(int i=n-1; i>=1; --i) st[0][i]=min(st[0][i],st[0][i+1]); for(int i=1; i<17; i++) for(int j=1; j<=n; j++){ if(st[i-1][j]==n+1)st[i][j]=n+1; else st[i][j]=st[i-1][st[i-1][j]]; } } int max_towers(int L,int R,int D) { l=L; r=R; m=D; if(m!=last)build(m); l=L+1; r=R+1; s4=0; for(int i=16; i>=0; --i){ if(st[i][l]<=r) { l=st[i][l]; s4+=mask(i); } } return s4+1; }/* void phongbeo() { cin>>n>>m; for(int i=0; i<n; i++) { cin>>s2; h.pb(s2); } init(n,h); cin>>l>>r>>k; cout<<max_towers(l,r,k); } */

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

towers.cpp:29:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+16' to '2147483647' [-Woverflow]
   29 | const int inf = 1e16;
      |                 ^~~~
#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...