結果

問題 No.3783 Choose Disjoint Semicircles
コンテスト
ユーザー askr58
提出日時 2026-09-21 05:12:01
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 496 ms / 2,000 ms
+ 999µs
コード長 587 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,117 ms
コンパイル使用メモリ 168,508 KB
実行使用メモリ 9,776 KB
平均クエリ数 4493.62
最終ジャッジ日時 2026-10-30 20:55:08
合計ジャッジ時間 12,759 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
using namespace std;
using ll=long long;
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int ttt;
	cin>>ttt;
	while(ttt--){
		int n;
		cin>>n;
		vector<int> p(n);
		for(int i=0;i<n;i++)cin>>p[i];
		int l=-1;
		for(int i=0;i<n;i++){
			if(p[i]==1){
				if(n%4==2)l=(i+n-n/4)%n;
				else{
					if(p[(i+1)%n]<p[(i+n-1)%n]){
						l=(i+n-n/4+1)%n;
					}else{
						l=(i+n-n/4)%n;
					}
				}
			}
		}
		int f=0;
		if(p[l]>p[(l+n/2-1)%n])f^=1;
		if(p[(l+n/2)%n]>p[(l+n-1)%n])f^=1;
		if(f)cout<<(l+n/2)%n<<endl;
		else cout<<l<<endl;
	}
}
0