Submission #893375

# Submission time Handle Problem Language Result Execution time Memory
893375 2023-12-27T03:38:39 Z 1075508020060209tc A Game with Grundy (CCO20_day1problem1) C++14
0 / 25
69 ms 6596 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
//#define Y second
vector<pair<int,int>>event;
int n;int L;int R;int Y;

int ans[500005];
void init(){
cin>>n;
cin>>L>>R>>Y;

for(int i=1;i<=n;i++){
    int a;int p;int q;
    cin>>a>>p>>q;
    int r=(Y+p*a/q)*q/p;
    r=Y*q/p+a;
    int l=(Y-p*a/q)*(-q)/p;
    l=Y*(-q)/p+a;
    if((Y*q)%p==0){r--;l++;}
    l=max(l,L);
    r=min(r,R);
    if(r>=l){
        event.push_back({l,1});
        event.push_back({r+1,-1});
    }
  //  cout<<l<<" "<<r<<"\n";
}

sort(event.begin(),event.end());
int tot=0;
int lst=L;
tot+=event[0].second;
for(int i=1;i<event.size();i++){
    ans[tot]+=event[i].first-event[i-1].first;
    tot+=event[i].second;
}
tot=R-L+1;
for(int i=1;i<=n;i++){
    tot-=ans[i];
    ans[i]+=ans[i-1];
}

for(int i=0;i<=n;i++){
    ans[i]+=tot;
    cout<<ans[i]<<"\n";
}



}


signed main(){
init();

}

Compilation message

Main.cpp: In function 'void init()':
Main.cpp:36:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 | for(int i=1;i<event.size();i++){
      |             ~^~~~~~~~~~~~~
Main.cpp:34:5: warning: unused variable 'lst' [-Wunused-variable]
   34 | int lst=L;
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 69 ms 6596 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 69 ms 6596 KB Output isn't correct
4 Halted 0 ms 0 KB -