結果
| 問題 |
No.2343 (l+r)/2
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2023-06-10 03:38:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 329 ms / 2,000 ms |
| コード長 | 1,226 bytes |
| コンパイル時間 | 4,237 ms |
| コンパイル使用メモリ | 254,016 KB |
| 最終ジャッジ日時 | 2025-02-14 01:15:36 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef modint998244353 mint;
typedef long long ll;
void dfs(int n, vector<double> v){
if (n == 1){
if (abs(v[0] - 0.5) < 0.001) cout << v[0] << endl;
return;
}
for (int i=0; i<n-1; i++){
vector<double> tmp;
for (int j=0; j<i; j++){
tmp.push_back(v[j]);
}
tmp.push_back((v[i] + v[i+1]) / 2);
for (int j=i+2; j<n; j++){
tmp.push_back(v[j]);
}
dfs(n-1, tmp);
}
}
void solve(){
int n; cin >> n;
vector<int> a(n);
for (int i=0; i<n; i++){
cin >> a[i];
}
int mode = 0;
for (int i=0; i<n; i++){
mode |= 1 << a[i];
}
if (mode != 3){
cout << "No\n";
return;
}
vector<int> runlength;
int var = -1;
int cnt = 0;
for (int i=0; i<n; i++){
if (var != a[i]){
if (var != -1){
runlength.push_back(cnt);
}
var = a[i];
cnt = 1;
}else{
cnt++;
}
}
runlength.push_back(cnt);
int m = runlength.size();
if (m % 2 == 0){
cout << "Yes\n";
return;
}
for (int i=1; i<m-1; i+=2){
if (runlength[i] > 1){
cout << "Yes\n";
return;
}
}
if (m <= 7){
cout << "No\n";
}else{
cout << "Yes\n";
}
return;
}
int main(){
int t; cin >> t;
while(t--) solve();
}
shobonvip