結果

問題 No.1508 Avoid being hit
ユーザー kotatsugamekotatsugame
提出日時 2021-05-14 22:39:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 818 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 68,936 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 01:24:06
合計ジャッジ時間 6,326 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 37 ms
6,944 KB
testcase_17 AC 22 ms
6,940 KB
testcase_18 AC 20 ms
6,944 KB
testcase_19 AC 32 ms
6,944 KB
testcase_20 AC 52 ms
6,940 KB
testcase_21 AC 34 ms
6,944 KB
testcase_22 AC 42 ms
6,944 KB
testcase_23 AC 44 ms
6,940 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 131 ms
6,940 KB
testcase_35 AC 14 ms
6,944 KB
testcase_36 AC 73 ms
6,944 KB
testcase_37 AC 32 ms
6,940 KB
testcase_38 AC 100 ms
6,944 KB
testcase_39 AC 64 ms
6,944 KB
testcase_40 AC 127 ms
6,940 KB
testcase_41 AC 70 ms
6,940 KB
testcase_42 AC 132 ms
6,944 KB
testcase_43 AC 157 ms
6,940 KB
testcase_44 AC 1 ms
6,944 KB
testcase_45 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,Q;
int A[1<<17],B[1<<17];
int L[1<<17],R[1<<17];
main()
{
	cin>>N>>Q;
	for(int i=0;i<Q;i++)cin>>A[i];
	for(int i=0;i<Q;i++)cin>>B[i];
	L[Q]=0,R[Q]=N+1;
	for(int i=Q;i--;)
	{
		if(A[i]>B[i])swap(A[i],B[i]);
		int l=L[i+1],r=R[i+1];
		if(A[i]==l+1||B[i]==l+1)
		{
			l++;
			if(A[i]==l&&B[i]==l+1)l++;
		}
		if(A[i]==r-1||B[i]==r-1)
		{
			r--;
			if(A[i]==r-1&&B[i]==r)r--;
		}
		if(l+1>=r)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		L[i]=l-1;
		R[i]=r+1;
		if(L[i]<0)L[i]=0;
		if(R[i]>N+1)R[i]=N+1;
	}
	cout<<"YES"<<endl;
	int pos=L[0]+1;
	cout<<pos<<endl;
	for(int i=0;i<Q;i++)
	{
		if(pos<=L[i])pos++;
		else if(pos>=R[i])pos--;
		else if(pos==A[i]||pos==B[i])
		{
			pos--;
			if(pos<=L[i]||pos==A[i]||pos==B[i])pos+=2;
		}
		cout<<pos<<endl;
	}
}
0