結果
問題 | No.678 2Dシューティングゲームの必殺ビーム |
ユーザー | horiesiniti |
提出日時 | 2016-07-01 16:44:23 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,255 bytes |
コンパイル時間 | 663 ms |
コンパイル使用メモリ | 53,920 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 03:48:05 |
合計ジャッジ時間 | 1,423 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%d %d %d",&n,&beamL,&beamR); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:33:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d %d %d %d",&xL,&yU,&xR,&yD); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:51:27: warning: ‘goalR’ may be used uninitialized in this function [-Wmaybe-uninitialized] 51 | for(int x=startL;x<=goalR;x++){ | ~^~~~~~~ main.cpp:51:27: warning: ‘startL’ may be used uninitialized in this function [-Wmaybe-uninitialized]
ソースコード
#include<stdio.h> #include<algorithm> #include<queue> #include<vector> struct E1{ int xL; int no; bool operator<(const E1& e1)const{ return xL>e1.xL; } }; struct E2{ int xR,y,no; bool operator<(const E2& e2)const{ return y<e2.y; } }; int main(){ int startL,goalR; int beamL,beamR; int n; scanf("%d %d %d",&n,&beamL,&beamR); std::vector<int> XLs,YUs,XRs,ans; std::priority_queue<E1> pq1; std::priority_queue<E2> pq2; for(int i=0;i<n;i++){ int xL,yU,xR,yD; scanf("%d %d %d %d",&xL,&yU,&xR,&yD); XLs.push_back(xL); YUs.push_back(yU); XRs.push_back(xR); ans.push_back(0); if(i==0){ startL=xL; goalR=xR; }else{ startL=std::min(startL,xL); goalR=std::max(goalR,xR); } E1 e1; e1.xL=xL; e1.no=i; pq1.push(e1); } for(int x=startL;x<=goalR;x++){ while(pq2.empty()==false){ E2 e2=pq2.top(); if(e2.xR>=x){ break; } pq2.pop(); } while(pq1.empty()==false){ E1 e1=pq1.top(); if(x<e1.xL){ break; } E2 e2; e2.no=e1.no; e2.xR=XRs[e1.no]; e2.y=YUs[e1.no]; pq2.push(e2); pq1.pop(); } if(pq2.empty()==false){ E2 e2=pq2.top(); if((beamL<=x)&&(x<=beamR)){ ans[e2.no]=1; } } } for(int i=0;i<ans.size();i++){ printf("%d\n",ans[i]); } }