結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 38 ms
6,940 KB
testcase_17 AC 21 ms
6,940 KB
testcase_18 AC 20 ms
6,940 KB
testcase_19 AC 33 ms
6,940 KB
testcase_20 AC 51 ms
6,944 KB
testcase_21 AC 34 ms
6,944 KB
testcase_22 AC 41 ms
6,944 KB
testcase_23 AC 45 ms
6,944 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 125 ms
6,940 KB
testcase_35 AC 14 ms
6,940 KB
testcase_36 AC 69 ms
6,940 KB
testcase_37 AC 31 ms
6,940 KB
testcase_38 AC 99 ms
6,940 KB
testcase_39 AC 65 ms
6,940 KB
testcase_40 AC 131 ms
6,944 KB
testcase_41 AC 76 ms
6,944 KB
testcase_42 AC 135 ms
6,940 KB
testcase_43 AC 157 ms
6,940 KB
testcase_44 AC 2 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]);
		L[i]=L[i+1]-1;
		if(A[i]==L[i+1]+1||B[i]==L[i+1]+1)L[i]++;
		if(A[i]==L[i+1]+1&&B[i]==L[i+1]+2)L[i]++;
		if(L[i]<0)L[i]=0;
		R[i]=R[i+1]+1;
		if(A[i]==R[i+1]-1||B[i]==R[i+1]-1)R[i]--;
		if(A[i]==R[i+1]-2&&B[i]==R[i+1]-1)R[i]--;
		if(R[i]>N+1)R[i]=N+1;
		if(L[i]+1>=R[i])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	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