結果
問題 | No.1016 三目並べ |
ユーザー |
![]() |
提出日時 | 2020-04-03 23:10:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,469 bytes |
コンパイル時間 | 1,829 ms |
コンパイル使用メモリ | 170,656 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 05:52:59 |
合計ジャッジ時間 | 2,129 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
#include<bits/stdc++.h> #include<unordered_set> #include<unordered_map> using namespace std; #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef long double ld; const ll inf=1e9+7; const ll mod=998244353; int main(){ ll t;cin>>t; while(t){ t--; ll n;string s;cin>>n>>s; string a="xxxx"; string b=""; b+=a+s+a; bool f=0; ll last=-1; ll cnt=0; rep(i,n){ ll c=i+4; if(b[c]=='x')cnt=0; if(b[c]=='-'&&cnt>0)cnt++; if(b[c]=='o'){ cnt++; if(cnt%2&&cnt>1)f=1; cnt=1; } if(b[c]=='o'&&b[c+1]=='-'&&b[c+2]=='o')f=1; if(b[c]=='o'&&b[c+1]=='o'&&b[c+2]=='-')f=1; if(b[c]=='-'&&b[c+1]=='o'&&b[c+2]=='o')f=1; if(b[c]=='o'&&b[c+1]=='o'&&b[c+2]=='o')f=1; if(b[c]=='o'&&b[c+1]=='-'&&b[c+2]=='o'&&b[c+3]=='-'&&b[c+4]=='o')f=1; if(b[c]=='-'&&b[c+1]=='o'&&b[c+2]=='-'&&b[c+3]=='-')f=1; if(b[c]=='-'&&b[c+1]=='-'&&b[c+2]=='o'&&b[c+3]=='-')f=1; if(b[c]=='o'&&b[c+1]=='-'&&b[c+2]=='-'&&b[c+3]=='-'&&b[c+4]=='o')f=1; } if(f)cout<<'O'<<endl; else cout<<'X'<<endl; } }