結果

問題 No.2002 Range Swap Query
ユーザー tailstails
提出日時 2023-03-11 17:08:35
言語 cLay
(20240104-1)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 384 bytes
コンパイル時間 7,312 ms
コンパイル使用メモリ 220,868 KB
実行使用メモリ 20,028 KB
最終ジャッジ日時 2023-10-18 10:04:44
合計ジャッジ時間 8,369 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,804 KB
testcase_01 AC 2 ms
7,804 KB
testcase_02 AC 2 ms
7,804 KB
testcase_03 AC 3 ms
7,804 KB
testcase_04 AC 2 ms
7,804 KB
testcase_05 AC 3 ms
7,804 KB
testcase_06 AC 2 ms
7,804 KB
testcase_07 AC 2 ms
7,804 KB
testcase_08 AC 3 ms
7,916 KB
testcase_09 AC 3 ms
8,108 KB
testcase_10 AC 3 ms
7,808 KB
testcase_11 AC 3 ms
7,956 KB
testcase_12 AC 46 ms
20,028 KB
testcase_13 AC 46 ms
20,028 KB
testcase_14 AC 45 ms
20,028 KB
testcase_15 AC 44 ms
19,816 KB
testcase_16 AC 33 ms
17,980 KB
testcase_17 AC 44 ms
20,028 KB
testcase_18 AC 28 ms
13,520 KB
testcase_19 AC 35 ms
16,860 KB
testcase_20 AC 26 ms
16,420 KB
testcase_21 AC 18 ms
13,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

int@n,@k,@q,a[k],b[],l[q],r[],x[],li[],ri[],p[n],s[];
rd((a--,b--)(k),(l--,r--,x--)(q));

sortA_index(q,l,li);
sortA_index(q,r,ri);
rep(i,n)s[i]=p[i]=i;
int lj=q-1,rj=q-1;
rrep(i,k){
	while(rj>=0&&r[rj]==i){
		x[ri[rj]]=p[x[ri[rj]]];
		--rj;
	}
	s[p[a[i]]]=b[i];
	s[p[b[i]]]=a[i];
	swap(p[a[i]],p[b[i]]);
	while(lj>=0&&l[lj]==i){
		x[li[lj]]=s[x[li[lj]]]+1;
		--lj;
	}
}

wtLn(x(q));
0