結果
問題 |
No.511 落ちゲー 〜手作業のぬくもり〜
|
ユーザー |
|
提出日時 | 2025-02-20 23:42:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,964 bytes |
コンパイル時間 | 1,566 ms |
コンパイル使用メモリ | 167,516 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-02-20 23:42:20 |
合計ジャッジ時間 | 3,125 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 5 |
other | WA * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | freopen("game.in","r",stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:11:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | freopen("game.out","w",stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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(){ freopen("game.in","r",stdin); freopen("game.out","w",stdout); 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; }