結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー vjudge1
提出日時 2025-02-25 20:33:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 158 ms / 4,000 ms
コード長 1,303 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 194,064 KB
実行使用メモリ 8,596 KB
最終ジャッジ日時 2025-02-25 20:33:57
合計ジャッジ時間 4,775 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
template<typename T>istream&operator>>(istream&I,vector<T>&v){for(auto&i:v)I>>i;return I;}
template<typename T>ostream&operator<<(ostream&O,vector<T>&v){for(auto&i:v)O<<i<<' ';return O;}
namespace AC{
int mx[400010],add[400010],T,n,h,A,B,tu;
void pushdown(int o){
	if(add[o]){
		mx[o<<1]+=add[o];
		mx[o<<1|1]+=add[o];
		add[o<<1]+=add[o];
		add[o<<1|1]+=add[o];
		add[o]=0;
	}
}
void get(int l,int r,int o){
	if(l==r){
		if(mx[o]>=h){
			mx[o]=-1e18;
			if(tu)A++;
			else B++;
		}
		return;
	}
	pushdown(o);
	int mid=(l+r)>>1;
	if(mx[o<<1]>=h)get(l,mid,o<<1);
	if(mx[o<<1|1]>=h)get(mid+1,r,o<<1|1);
	mx[o]=max(mx[o<<1],mx[o<<1|1]);
}
void upd(int l,int r,int o,int L,int R,int z){
	if(l>=L&&r<=R){
		mx[o]+=z;
		add[o]+=z;
		if(mx[o]>=h)get(l,r,o);
		return;
	}
	pushdown(o);
	int mid=(l+r)>>1;
	if(L<=mid)upd(l,mid,o<<1,L,R,z);
	if(R>mid)upd(mid+1,r,o<<1|1,L,R,z);
	mx[o]=max(mx[o<<1],mx[o<<1|1]);
}
void solve(){
	cin>>T>>n>>h;
	while(T--){
	    tu^=1;
		int a,b,x;
		cin>>a>>b>>x;
		upd(1,n,1,x,a+x-1,b);
	}
	if(A>B)cout<<"A";
	else if(A<B)cout<<"B";
	else cout<<"DRAW";
	//cout<<endl<<A<<' '<<B;
}
}
signed main(){
	int t=1;
	//cin>>t;
	while(t--)AC::solve();
}
0