結果
問題 | No.1016 三目並べ |
ユーザー |
![]() |
提出日時 | 2020-04-03 21:56:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,250 bytes |
コンパイル時間 | 1,612 ms |
コンパイル使用メモリ | 170,552 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-03 02:29:38 |
合計ジャッジ時間 | 2,132 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(),(x).end() const int mod=1000000007,MAX=200005,INF=1<<30; vector<string> win={"ooo","--o-","-o--","-oo","oo-","o-o"}; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int Q;cin>>Q; while(Q--){ int N;string S;cin>>N>>S; bool ok=false; for(int i=0;i<N;i++){ for(int j=0;j<6;j++){ bool check=true; if(i+win[j].size()>N) continue; for(int k=0;k<win[j].size();k++){ if(S[i+k]!=win[j][k]) check=false; } if(check) ok=true; } } int i=0; while(i<N){ while(i<N&&S[i]!='o') i++; if(i>=N) break; int j=i+1; while(j<N&&S[j]=='-') j++; if(j>=N) break; if(S[j]!='o'){ i=j; continue; } if((j-i)%2==0) ok=true; i=j; } if(ok) cout<<"O\n"; else cout<<"X\n"; } }