結果

問題 No.1508 Avoid being hit
ユーザー kotatsugamekotatsugame
提出日時 2021-05-14 22:25:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 847 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 69,512 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 00:56:11
合計ジャッジ時間 6,441 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 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 1 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 35 ms
6,944 KB
testcase_17 AC 22 ms
6,940 KB
testcase_18 AC 20 ms
6,940 KB
testcase_19 AC 31 ms
6,944 KB
testcase_20 AC 54 ms
6,940 KB
testcase_21 AC 34 ms
6,940 KB
testcase_22 AC 40 ms
6,944 KB
testcase_23 AC 46 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 124 ms
6,940 KB
testcase_35 AC 15 ms
6,944 KB
testcase_36 AC 68 ms
6,944 KB
testcase_37 AC 32 ms
6,940 KB
testcase_38 AC 103 ms
6,940 KB
testcase_39 AC 65 ms
6,940 KB
testcase_40 AC 131 ms
6,944 KB
testcase_41 AC 78 ms
6,940 KB
testcase_42 AC 128 ms
6,940 KB
testcase_43 AC 149 ms
6,940 KB
testcase_44 AC 2 ms
6,940 KB
testcase_45 AC 1 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[0]+1<R[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;
		}
	}
	else
	{
		cout<<"NO"<<endl;
	}
}
0