結果
問題 |
No.1016 三目並べ
|
ユーザー |
|
提出日時 | 2020-06-20 06:55:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 640 bytes |
コンパイル時間 | 1,885 ms |
コンパイル使用メモリ | 195,164 KB |
最終ジャッジ日時 | 2025-01-11 08:27:27 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:40:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | int q; scanf("%d",&q); rep(_,q) solve(); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; bool check(string s){ int n=s.length(); // oo?, o?o, ?oo rep(i,n-2){ if(count(s.begin()+i,s.begin()+i+3,'o')>=2) return true; } // ?o??, ??o? rep(i,n-3){ if(s[i+1]=='o' || s[i+2]=='o') return true; } // o???o rep(i,n-4){ if(s[i]=='o' && s[i+4]=='o') return true; } return false; } void solve(){ int n; string s; cin>>n>>s; int pre=0; rep(i,n+1) if(i==n || s[i]=='x') { if(check(s.substr(pre,i-pre))){ puts("O"); return; } pre=i+1; } puts("X"); } int main(){ int q; scanf("%d",&q); rep(_,q) solve(); return 0; }