結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー vjudge1
提出日時 2025-02-23 14:59:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,302 bytes
コンパイル時間 1,916 ms
コンパイル使用メモリ 193,916 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-23 14:59:21
合計ジャッジ時間 3,587 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 31 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//#define int long long
//#define int __int128
using namespace std;
inline int read()
{
   int x=0,f=1;char ch=getchar();
   while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
   while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}
   return x*f;
}
void write(int x)
{
   if(x<0)putchar('-'),x=-x;
   if(x<10)putchar(x+'0');
   else write(x/10),putchar(x%10+'0');
}
const int N=3e5;
const int mod=1e9+7;
int n,w;
long long h;
int top;
long long W[N];
int f[N];
int root(int x){
	if(f[x]==x)return x;
	return f[x]=root(f[x]);
}
int ans[20];
bool fl;
int sum;
signed main(){
//	freopen("game.in","r",stdin);
//	freopen("game.out","w",stdout);
	n=read(),w=read(),h=read();
	for(int i=0;i<=w;i++)f[i]=i;
	for(int i=1;i<=n;++i){
		int a=read(),b=read(),x=read();
		for(int j=root(f[x]);j<=a+x-1&&j!=0&&j<=w;){
			W[j]+=b;
			if(W[j]>=h){
				W[j]=LONG_LONG_MIN;
				ans[fl]++;
				sum++;
				f[root(j)]=root(f[j+1]);
				j=root(f[j]);
			}
			else{
				j=root(f[j+1]);
			}
		}
		fl^=1;
		if(sum==w){
			if(ans[0]==ans[1])cout<<"DRAW\n";
			else cout<<(ans[0]>ans[1]?"A":"B")<<"\n";
		//	cout<<ans[0]<<" "<<ans[1]<<"\n";
			return 0;
		}
	}
	if(ans[0]==ans[1])cout<<"DRAW\n";
	else cout<<(ans[0]>ans[1]?"A":"B")<<"\n";
//	cout<<ans[0]<<" "<<ans[1]<<"\n";
  return 0;
}
0