結果

問題 No.5011 Better Mo's Algorithm is Needed!! (Weighted)
ユーザー tailstails
提出日時 2022-12-17 14:45:55
言語 cLay
(20240104-1)
結果
AC  
実行時間 4,966 ms / 5,000 ms
コード長 839 bytes
コンパイル時間 3,586 ms
実行使用メモリ 18,392 KB
スコア 42,667,521,828
最終ジャッジ日時 2022-12-17 14:56:48
合計ジャッジ時間 647,151 ms
ジャッジサーバーID
(参考情報)
judge16 / judge12
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4,960 ms
16,480 KB
testcase_01 AC 4,960 ms
16,360 KB
testcase_02 AC 4,959 ms
16,488 KB
testcase_03 AC 4,962 ms
16,352 KB
testcase_04 AC 4,959 ms
16,356 KB
testcase_05 AC 4,961 ms
16,520 KB
testcase_06 AC 4,960 ms
16,408 KB
testcase_07 AC 4,960 ms
16,436 KB
testcase_08 AC 4,960 ms
16,368 KB
testcase_09 AC 4,960 ms
16,520 KB
testcase_10 AC 4,960 ms
16,416 KB
testcase_11 AC 4,960 ms
16,492 KB
testcase_12 AC 4,959 ms
16,356 KB
testcase_13 AC 4,958 ms
16,432 KB
testcase_14 AC 4,958 ms
16,468 KB
testcase_15 AC 4,960 ms
16,372 KB
testcase_16 AC 4,960 ms
16,512 KB
testcase_17 AC 4,960 ms
16,440 KB
testcase_18 AC 4,959 ms
16,512 KB
testcase_19 AC 4,960 ms
16,372 KB
testcase_20 AC 4,958 ms
16,356 KB
testcase_21 AC 4,960 ms
16,352 KB
testcase_22 AC 4,958 ms
16,444 KB
testcase_23 AC 4,959 ms
16,472 KB
testcase_24 AC 4,958 ms
16,360 KB
testcase_25 AC 4,957 ms
16,476 KB
testcase_26 AC 4,960 ms
16,364 KB
testcase_27 AC 4,961 ms
16,412 KB
testcase_28 AC 4,958 ms
16,480 KB
testcase_29 AC 4,959 ms
16,376 KB
testcase_30 AC 4,958 ms
16,352 KB
testcase_31 AC 4,959 ms
16,408 KB
testcase_32 AC 4,960 ms
16,356 KB
testcase_33 AC 4,958 ms
16,520 KB
testcase_34 AC 4,958 ms
16,496 KB
testcase_35 AC 4,957 ms
16,472 KB
testcase_36 AC 4,957 ms
16,360 KB
testcase_37 AC 4,958 ms
16,412 KB
testcase_38 AC 4,958 ms
16,480 KB
testcase_39 AC 4,958 ms
16,516 KB
testcase_40 AC 4,958 ms
16,528 KB
testcase_41 AC 4,959 ms
16,516 KB
testcase_42 AC 4,959 ms
16,516 KB
testcase_43 AC 4,960 ms
16,396 KB
testcase_44 AC 4,958 ms
16,444 KB
testcase_45 AC 4,959 ms
16,352 KB
testcase_46 AC 4,957 ms
18,228 KB
testcase_47 AC 4,959 ms
18,264 KB
testcase_48 AC 4,958 ms
16,520 KB
testcase_49 AC 4,957 ms
18,280 KB
testcase_50 AC 4,960 ms
16,516 KB
testcase_51 AC 4,958 ms
16,528 KB
testcase_52 AC 4,959 ms
16,444 KB
testcase_53 AC 4,958 ms
18,312 KB
testcase_54 AC 4,959 ms
18,268 KB
testcase_55 AC 4,958 ms
18,284 KB
testcase_56 AC 4,958 ms
18,232 KB
testcase_57 AC 4,957 ms
18,224 KB
testcase_58 AC 4,958 ms
18,244 KB
testcase_59 AC 4,960 ms
18,312 KB
testcase_60 AC 4,957 ms
18,292 KB
testcase_61 AC 4,958 ms
18,224 KB
testcase_62 AC 4,957 ms
18,232 KB
testcase_63 AC 4,959 ms
18,240 KB
testcase_64 AC 4,959 ms
18,312 KB
testcase_65 AC 4,958 ms
18,352 KB
testcase_66 AC 4,960 ms
18,232 KB
testcase_67 AC 4,958 ms
18,280 KB
testcase_68 AC 4,961 ms
18,276 KB
testcase_69 AC 4,966 ms
18,308 KB
testcase_70 AC 4,959 ms
18,236 KB
testcase_71 AC 4,958 ms
18,388 KB
testcase_72 AC 4,959 ms
18,244 KB
testcase_73 AC 4,960 ms
18,316 KB
testcase_74 AC 4,958 ms
18,232 KB
testcase_75 AC 4,959 ms
18,356 KB
testcase_76 AC 4,957 ms
18,284 KB
testcase_77 AC 4,959 ms
18,368 KB
testcase_78 AC 4,959 ms
18,388 KB
testcase_79 AC 4,958 ms
18,240 KB
testcase_80 AC 4,958 ms
18,392 KB
testcase_81 AC 4,957 ms
18,344 KB
testcase_82 AC 4,959 ms
18,368 KB
testcase_83 AC 4,959 ms
18,232 KB
testcase_84 AC 4,959 ms
18,240 KB
testcase_85 AC 4,958 ms
18,364 KB
testcase_86 AC 4,958 ms
18,236 KB
testcase_87 AC 4,958 ms
18,284 KB
testcase_88 AC 4,959 ms
18,276 KB
testcase_89 AC 4,958 ms
18,312 KB
testcase_90 AC 4,958 ms
18,284 KB
testcase_91 AC 4,960 ms
18,284 KB
testcase_92 AC 4,959 ms
18,348 KB
testcase_93 AC 4,959 ms
18,264 KB
testcase_94 AC 4,957 ms
18,360 KB
testcase_95 AC 4,959 ms
18,292 KB
testcase_96 AC 4,959 ms
18,232 KB
testcase_97 AC 4,960 ms
18,240 KB
testcase_98 AC 4,959 ms
18,308 KB
testcase_99 AC 4,958 ms
18,224 KB
testcase_100 AC 4,959 ms
18,352 KB
testcase_101 AC 4,959 ms
18,268 KB
testcase_102 AC 4,958 ms
18,312 KB
testcase_103 AC 4,958 ms
18,292 KB
testcase_104 AC 4,958 ms
18,240 KB
testcase_105 AC 4,958 ms
18,308 KB
testcase_106 AC 4,959 ms
18,312 KB
testcase_107 AC 4,960 ms
18,368 KB
testcase_108 AC 4,958 ms
18,264 KB
testcase_109 AC 4,960 ms
18,308 KB
testcase_110 AC 4,957 ms
18,268 KB
testcase_111 AC 4,958 ms
18,284 KB
testcase_112 AC 4,959 ms
18,388 KB
testcase_113 AC 4,958 ms
18,316 KB
testcase_114 AC 4,959 ms
18,224 KB
testcase_115 AC 4,959 ms
18,244 KB
testcase_116 AC 4,958 ms
16,368 KB
testcase_117 AC 4,959 ms
16,372 KB
testcase_118 AC 4,959 ms
16,408 KB
testcase_119 AC 4,960 ms
16,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ull xs[2d5];
ll ys[2d5];
ll ls[2d5],rs[2d5];

ll d(ll i,ll j){
	return abs(ls[ys[j]]-ls[ys[i]])+abs(rs[ys[j]]-rs[ys[i]]);
}

void opt1(ll b){
	rep(i,2d5-1-b){
		if(d(i,i+1)+d(i+b,i+b+1)>d(i,i+b)+d(i+1,i+b+1)){
			reverse(ys+(i+1),ys+(i+1+b));
		}
	}
}

{
	Timer timer;
	timer.set();

	ll@n,@q,@wt,@st,w[n+1];
	rep(i,n){
		ll@wi;
		w[i+1]=w[i]+wi;
	}
	rep(i,q){
		ll@l,@r;
		ls[i]=l=w[l-1];
		rs[i]=r=w[r];
		ll m=w[n]+1>>1;
		ull x=0;
		rep(32){
			x<<=2;
			if(r<m){
				x|=0;
				(l,r)=(l,r);
			}else if(l>=m){
				x|=3;
				(l,r)=(l-m,r-m);
			}else if(l+r<2m){
				x|=1;
				(l,r)=(r-m,m-1-l);
			}else{
				x|=2;
				(l,r)=(2m-1-r,l);
			}
			l*=2;
			r*=2;
		}
		xs[i]=x;
		ys[i]=i;
	}
	sortA(q,xs,ys);

	rrep(i,4096){
		long k=i%512+2;
		opt1(k);
		if(timer.get()>=4.95){
			break;
		}
	}
	
	rep(i,q){
		ys[i]+=1;
	}
	wt(ys(q));
}
0