結果

問題 No.2283 Prohibit Three Consecutive
ユーザー Eil_kyoproEil_kyopro
提出日時 2023-04-28 22:08:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,505 bytes
コンパイル時間 4,282 ms
コンパイル使用メモリ 229,356 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 23:42:05
合計ジャッジ時間 5,103 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 20 ms
5,376 KB
testcase_04 AC 20 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 13 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vvvl=vector<vector<vector<long long>>>;
using pl=pair<long long,long long>;
using vpl=vector<pair<long long,long long>>;
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#include <atcoder/all>
using namespace atcoder;

long long modpow(long long a, long long n, long long mo){long long res=1;while(n>0){if(n&1){res=res*a%mo;}a=a*a%mo;n>>=1;}return res;}
long long Pow(long long a, long long n){long long res=1;while(n>0){if(n&1){res=res*a;}a=a*a;n>>=1;}return res;}

const ll MOD=998244353;
const ll INF=(1ll<<60);
int main(){
  ll T;
  cin>>T;
  rep(i,T){
    ll N;
    cin>>N;
    string S;
    cin>>S;
    bool ans=true;
    rep(i,N){
      if(S[i]==S[(i+1)%N] && S[i]==S[(i+2)%N] && S[i]!='?') ans=false;
    }
    rep(i,N){
      if(S[i]==S[(i+1)%N] && S[(i+3)%N]==S[(i+4)%N] && S[i]!=S[(i+3)%N] && S[i]!='?' && S[(i+3)%N]!='?') ans=false;
    }
    rep(i,N){
      if(S[i]==S[(i+1)%N] && S[(i+2)%N]=='?' && S[(i+3)%N]!=S[i] && S[(i+3)%N]!='?' && S[(i+4)%N]=='?' && S[i]==S[(i+5)%N] && S[i]==S[(i+6)%N]) ans=false;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}
0