Submission #1093803

# Submission time Handle Problem Language Result Execution time Memory
1093803 2024-09-27T14:40:22 Z 8pete8 A Game with Grundy (CCO20_day1problem1) C++17
0 / 25
1 ms 348 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<cassert>
#include<unordered_map>
#include <queue>
#include <cstdint>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
#define int long long
#define double long double
using namespace std;
const int mod=998244353,mxn=2e5+5,inf=1e18,minf=-1e18,lg=30;
//#undef int
int n,k,m,q;
void setIO(string name){		
	ios_base::sync_with_stdio(0); cin.tie(0);		
	freopen((name+".in").c_str(),"r",stdin);		
	freopen((name+".out").c_str(),"w",stdout);	
}
struct line{
	double m,c;
	void init(int a,int b,int x){
		m=(a*1.0/b);
		c=m*(-x);
	}
};
int div(double a,double b){
	if(a*b>=0)return a*1.0/b;
	return (a*1.0/b)-1;
}
int32_t main(){
    fastio
	cin>>n;
	int l,r,y;cin>>l>>r>>y;
	line base;
	base.m=0,base.c=y;
	map<int,int>cnt;
	for(int i=0;i<n;i++){
		int x,a,b;cin>>x>>a>>b;
		line p,q;
		p.init(a,b,x),q.init(-a,b,x);
		int pos=div(base.c-q.c,q.m-base.m)+1,pos2=ceil((base.c-p.c)/(p.m-base.m));
		cnt[max(pos,l)]++;
		cnt[min(pos2,r+1)]--;
	}
	vector<int>ans(n+1,0);
	int curcnt=0,last=l;
	for(auto i:cnt){
		if(i.f>r)break;
		if(i.f>=l){
			ans[curcnt]+=abs(i.f-last);
			curcnt+=i.s;
		}
		last=max(last,i.f);
	}
	ans[curcnt]+=abs(r-last)+1;
	for(int i=0;i<=n;i++){
		if(i)ans[i]+=ans[i-1];
		cout<<ans[i]<<'\n';
	}
}
/*
*/

Compilation message

Main.cpp:32:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
   32 | #pragma GCC optimize ("03,unroll-lopps")
      |                                        ^
Main.cpp:39:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   39 | void setIO(string name){
      |                       ^
Main.cpp:46:29: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   46 |  void init(int a,int b,int x){
      |                             ^
Main.cpp:51:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   51 | int div(double a,double b){
      |                          ^
Main.cpp:55:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   55 | int32_t main(){
      |              ^
Main.cpp: In function 'void setIO(std::string)':
Main.cpp:41:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:42:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -