結果

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 100010 
#define len 27
#define M 4000
int n,w,h,a,b,x,ex[M],cnt[N],z[N],ansa,ansb;
multiset<int> s[M];
signed main(){
	cin>>n>>w>>h;
	for(int i=1;i<=w;i++){
		z[i]=(i+len-1)/len;
		cnt[i]=h;
		s[z[i]].insert(h);
	}
	for(int t=1;t<=n;t++){
		cin>>a>>b>>x;
		int pre=b;
		b=x+a-1;
		a=x;
		x=pre;
		if(z[a]==z[b]){
			for(int i=a;i<=b;i++){
				if(s[z[i]].find(cnt[i])==s[z[i]].end()){
					continue;
				}
				s[z[i]].erase(s[z[i]].find(cnt[i]));
				cnt[i]-=x;
				s[z[i]].insert(cnt[i]);
			}
			while((!s[z[a]].empty())&&(*s[z[a]].begin()<=ex[z[a]])){
				if(t%2==1){
					ansa++;
				}
				else{
					ansb++;
				}
				s[z[a]].erase(s[z[a]].find((*s[z[a]].begin())));
			}
		}
		else{
			for(int i=z[a]*len+1;i<=(z[b]-1)*len;i+=len){
				ex[z[i]]+=x;
				while(!s[z[i]].empty()&&(*s[z[i]].begin()<=ex[z[i]])){
					if(t%2==1){
						ansa++;
					}
					else{
						ansb++;
					}
					s[z[i]].erase(s[z[i]].find((*s[z[i]].begin())));
				}
			}
			for(int i=a;i<=z[a]*len;i++){
				if(s[z[i]].find(cnt[i])==s[z[i]].end()){
					continue;
				}
				s[z[i]].erase(s[z[i]].find(cnt[i]));
				cnt[i]-=x;
				s[z[i]].insert(cnt[i]);
			}
			while(!s[z[a]].empty()&&(*s[z[a]].begin()<=ex[z[a]])){
				if(t%2==1){
					ansa++;
				}
				else{
					ansb++;
				}
				s[z[a]].erase(s[z[a]].find((*s[z[a]].begin())));
			}
			for(int i=(z[b]-1)*len+1;i<=b;i++){
				if(s[z[i]].find(cnt[i])==s[z[i]].end()){
					continue;
				}
				s[z[i]].erase(s[z[i]].find(cnt[i]));
				cnt[i]-=x;
				s[z[i]].insert(cnt[i]);
			}
			while(!s[z[b]].empty()&&(*s[z[b]].begin()<=ex[z[b]])){
				if(t%2==1){
					ansa++;
				}
				else{
					ansb++;
				}
				s[z[b]].erase(s[z[b]].find((*s[z[b]].begin())));
			}
		}
	}
	if(ansa<ansb){
		cout<<"B"<<endl;
	}
	else if(ansa==ansb){
		cout<<"DRAW"<<endl;
	}
	else{
		cout<<"A"<<endl;
	}
	return 0;
}
0