結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 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 40 ms
6,940 KB
testcase_17 AC 23 ms
6,940 KB
testcase_18 AC 22 ms
6,940 KB
testcase_19 AC 34 ms
6,940 KB
testcase_20 AC 54 ms
6,944 KB
testcase_21 AC 35 ms
6,944 KB
testcase_22 AC 43 ms
6,940 KB
testcase_23 AC 47 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 131 ms
6,944 KB
testcase_35 AC 14 ms
6,940 KB
testcase_36 AC 73 ms
6,944 KB
testcase_37 AC 33 ms
6,940 KB
testcase_38 AC 105 ms
6,940 KB
testcase_39 AC 68 ms
6,940 KB
testcase_40 AC 134 ms
6,940 KB
testcase_41 AC 79 ms
6,940 KB
testcase_42 AC 137 ms
6,940 KB
testcase_43 AC 162 ms
6,940 KB
testcase_44 AC 2 ms
6,940 KB
testcase_45 AC 2 ms
6,940 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;
		}
		if(L[i]+2==R[i]&&(L[i]+1==A[i]||L[i]+1==B[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