답안 #902240

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
902240 2024-01-10T07:28:12 Z pcc A Game with Grundy (CCO20_day1problem1) C++14
0 / 25
87 ms 6252 KB
#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] += min(R+1,all[i+1])-max(L,all[i]);
	}
	for(int i = 0;i<=N;i++){
		if(i)ans[i] += ans[i-1];
		cout<<ans[i]<<'\n';
	}
	return 0;
}

Compilation message

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++){
      |                ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 87 ms 6252 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Incorrect 87 ms 6252 KB Output isn't correct
4 Halted 0 ms 0 KB -