結果
問題 | No.1016 三目並べ |
ユーザー | pockyny |
提出日時 | 2020-04-03 22:40:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 1,113 bytes |
コンパイル時間 | 832 ms |
コンパイル使用メモリ | 70,112 KB |
最終ジャッジ日時 | 2025-01-09 13:24:50 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
#include <iostream> #include <string> using namespace std; string s[5] = {"--o-","-o--","oo-","-oo","ooo"}; bool ch(string st,string u){ int i,j,n = st.size(),k = u.size(); for(i=0;i<n;i++){ for(j=0;j<k;j++){ if(i + j>=n || st[i + j]!=u[j]) break; if(j==k - 1) return true; } } return false; } bool ch2(string st){ int i,n = st.size(); int l = -1; bool flag = false; for(i=1;i<n;i++){ if(st[i]=='-'){ if(!flag) l = i - 1; flag = true; }else if(flag){ flag = false; if(st[l]=='o' && st[i]=='o' && (i - l)%2==0){ return true; } } } return false; } int main(){ int i,t; cin >> t; while(t){ t--; int n; string st; cin >> n >> st; for(i=0;i<5;i++){ if(ch(st,s[i])){ cout << "O" << endl; break; } if(i==4){ if(ch2(st)) cout << "O" << endl; else cout << "X" << endl; } } } }