結果

問題 No.678 2Dシューティングゲームの必殺ビーム
ユーザー 👑 horiesinitihoriesiniti
提出日時 2016-07-01 16:44:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,255 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 54,200 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 08:25:36
合計ジャッジ時間 1,365 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]

ソースコード

diff #

#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]);
	}
}
0