結果

問題 No.2002 Range Swap Query
ユーザー tailstails
提出日時 2023-03-11 17:03:00
言語 cLay
(20240104-1)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 6,796 ms
コンパイル使用メモリ 219,992 KB
実行使用メモリ 30,716 KB
最終ジャッジ日時 2023-10-18 10:04:21
合計ジャッジ時間 9,801 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,848 KB
testcase_01 AC 2 ms
7,848 KB
testcase_02 AC 2 ms
7,848 KB
testcase_03 AC 2 ms
7,848 KB
testcase_04 AC 2 ms
7,848 KB
testcase_05 AC 2 ms
7,848 KB
testcase_06 AC 2 ms
7,848 KB
testcase_07 AC 3 ms
7,848 KB
testcase_08 AC 3 ms
8,056 KB
testcase_09 AC 3 ms
8,376 KB
testcase_10 AC 2 ms
7,864 KB
testcase_11 AC 3 ms
8,108 KB
testcase_12 AC 70 ms
30,716 KB
testcase_13 AC 71 ms
30,712 KB
testcase_14 AC 74 ms
30,712 KB
testcase_15 AC 71 ms
30,288 KB
testcase_16 AC 43 ms
26,620 KB
testcase_17 AC 58 ms
30,716 KB
testcase_18 AC 35 ms
19,744 KB
testcase_19 AC 42 ms
24,424 KB
testcase_20 AC 37 ms
25,544 KB
testcase_21 AC 24 ms
19,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@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;
ll 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