Submission #902241

#TimeUsernameProblemLanguageResultExecution timeMemory
902241pccA Game with Grundy (CCO20_day1problem1)C++14
25 / 25
105 ms7448 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> const int mxn = 1e5+10; const ll inf = 2e9+10; int cnt[mxn*2]; int ans[mxn]; vector<ll> all; pll range[mxn]; ll N,L,R,Y; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>L>>R>>Y; for(int i = 0;i<N;i++){ ll a,b,x; cin>>x>>a>>b; ll l = -inf,r = inf; while(l != r){ ll mid = l+(r-l)/2; if((x-mid)*a<Y*b)r = mid; else l = mid+1; } range[i].fs = l; l = -inf,r = inf; while(l != r){ ll mid = l+(r-l+1)/2; if((mid-x)*a<Y*b)l = mid; else r = mid-1; } range[i].sc = r+1; all.push_back(range[i].fs); all.push_back(range[i].sc); } all.push_back(L); all.push_back(R+1); sort(all.begin(),all.end()); all.resize(unique(all.begin(),all.end())-all.begin()); for(int i = 0;i<N;i++){ int l = lower_bound(all.begin(),all.end(),range[i].fs)-all.begin(); int r = lower_bound(all.begin(),all.end(),range[i].sc)-all.begin(); cnt[l]++,cnt[r]--; } int sum = 0; for(int i = 0;i+1<all.size();i++){ sum += cnt[i]; ans[sum] += max(min(R+1,all[i+1])-max(L,all[i]),0ll); } for(int i = 0;i<=N;i++){ if(i)ans[i] += ans[i-1]; cout<<ans[i]<<'\n'; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:53:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |  for(int i = 0;i+1<all.size();i++){
      |                ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...