結果
| 問題 |
No.511 落ちゲー 〜手作業のぬくもり〜
|
| コンテスト | |
| ユーザー |
latte0119
|
| 提出日時 | 2017-04-28 22:50:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 165 ms / 4,000 ms |
| コード長 | 2,011 bytes |
| コンパイル時間 | 1,768 ms |
| コンパイル使用メモリ | 163,584 KB |
| 実行使用メモリ | 9,472 KB |
| 最終ジャッジ日時 | 2024-11-24 12:40:13 |
| 合計ジャッジ時間 | 3,727 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:62:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
62 | scanf("%lld%lld%lld",&N,&W,&H);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:68:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
68 | scanf("%lld%lld%lld",&a,&b,&x);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
const int INF=1001001001001001001ll;
struct segtree{
static const int SEG=1<<17;
vpint dat;
vint put;
segtree(int n):dat(SEG*2,pint(-INF,0)),put(SEG*2,0){
for(int i=0;i<n;i++){
dat[i+SEG-1].fi=0;
dat[i+SEG-1].se=i;
}
for(int i=SEG-2;i>=0;i--)dat[i]=max(dat[i*2+1],dat[i*2+2]);
}
inline void push(int k){
dat[k].fi+=put[k];
if(k<SEG-1){
put[k*2+1]+=put[k];
put[k*2+2]+=put[k];
}
put[k]=0;
}
void add(int a,int b,int x,int k=0,int l=0,int r=SEG){
push(k);
if(r<=a||b<=l)return;
if(a<=l&&r<=b){
put[k]+=x;
push(k);
return;
}
add(a,b,x,k*2+1,l,(l+r)/2);
add(a,b,x,k*2+2,(l+r)/2,r);
dat[k]=max(dat[k*2+1],dat[k*2+2]);
}
pint query(int a,int b,int k=0,int l=0,int r=SEG){
push(k);
if(r<=a||b<=l)return pint(-INF,0);
if(a<=l&&r<=b)return dat[k];
return max(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
}
};
signed main(){
int N,W,H;
scanf("%lld%lld%lld",&N,&W,&H);
segtree seg(W);
int P[2]={};
rep(i,N){
int a,b,x;
scanf("%lld%lld%lld",&a,&b,&x);
x--;
seg.add(x,x+a,b);
while(true){
auto p=seg.query(0,W);
if(p.fi<H)break;
seg.add(p.se,p.se+1,-INF);
P[i&1]++;
}
}
if(P[0]>P[1])cout<<"A"<<endl;
else if(P[0]<P[1])cout<<"B"<<endl;
else cout<<"DRAW"<<endl;
return 0;
}
latte0119