Submission #577939

#TimeUsernameProblemLanguageResultExecution timeMemory
577939MohamedFaresNebiliA Game with Grundy (CCO20_day1problem1)C++14
25 / 25
265 ms6984 KiB
#include <bits/stdc++.h> using namespace std; double inters(double a, double b, double y){ double p = (y-b)/(double)a; return p; } int main() { long long count0[100005]; memset(count0,0,sizeof count0); int n, l, r, y; cin >> n >> l >> r >> y; vector<pair<double,int>> pnts; for(int i = 0;i<n;i++){ int x, v, h; cin >> x >> v >> h; double a = v/(double)h; double b = -a*x; pnts.push_back({inters(a,b,y),-1}); pnts.push_back({inters(-a,-b,y),1}); } for(int i = 0;i<pnts.size();i++){ if(pnts[i].second == 1)pnts[i].first += 10e-6; else pnts[i].first -= 10e-6; } sort(pnts.begin(), pnts.end()); int left = l, c = 0; for(int i = 0; i < pnts.size(); i++){ if(pnts[i].first > r)break; if(pnts[i].first < l){ if(pnts[i].second == 1) c++; else c--; continue; } count0[c] += ceil(pnts[i].first) - left; if(pnts[i].second == 1) c++; else c--; left = ceil(pnts[i].first); } count0[c] += r - left + 1; for(int i = 0; i <= n; i++){ if(i != 0) count0[i] += count0[i-1]; cout << count0[i] << endl; } }

Compilation message (stderr)

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