Submission #292916

#TimeUsernameProblemLanguageResultExecution timeMemory
292916FidiskA Game with Grundy (CCO20_day1problem1)C++14
0 / 25
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define oo 1e18 #define fi first #define se second #define sp(iiii) setprecision(iiii) #define IO ios_base::sync_with_stdio(false); cin.tie(0) #define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa)) #define cntbit(xxxx) __builtin_popcount(xxxx) #define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1) #define _cos(xxxx) cos(xxxx*acos(-1)/180) #define _sin(xxxx) sin(xxxx*acos(-1)/180) #define _tan(xxxx) tan(xxxx*acos(-1)/180) #define PE cout<<fixed typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<pair<int,int>,int> piii; typedef pair<long long,long long> pll; typedef pair<pair<long long,long long>,long long> plll; const ld pi=acos(-1); ll n,l,r,y,i,x,v,h,pl,pr,sl,last,cur,res[500009],ans[500009]; pll a[500009]; int main() { IO; cin>>n; cin>>l>>r>>y; for (i=1;i<=n;i++) { cin>>x>>v>>h; pl=x+(v*y+h-1)/h; pr=x+(v*y+h-1)/h; //cout<<pl<<' '<<pr<<' '<<((ld)(-(((ld)h)*((ld)y))/((ld)v)))<<' '<<((ld)((((ld)h)*((ld)y))/((ld)v)))<<'\n'; a[i*2-1]={pl,1}; a[i*2]={pr+1,-1}; } sort(a+1,a+n+n+1); last=l; cur=0; for (i=1;i<=2*n;i++) { res[cur]+=max(a[i].fi-last,i-i); cur+=a[i].se; last=max(last,min(a[i].fi,r)); } ans[n]=(r-l)+1; for (i=n-1;i>=0;i--) { ans[i]=ans[i+1]-res[i+1]; } for (i=0;i<=n;i++) { cout<<ans[i]<<'\n'; } /* cout<<'\n'; for (i=1;i<=2*n;i++) { cout<<a[i].fi<<' '; } cout<<'\n'; for (i=1;i<=2*n;i++) { cout<<a[i].se<<' '; } */ }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...