Official
A - ○✕ゲーム/OX Game Editorial by tatyam
問題文の通りに、 o
が \(3\) つ並んでいるか、 x
が \(3\) つ並んでいるかを判定すればよいです。
回答例 (C++)
#include <iostream>
#include <string>
using namespace std;
int main(){
string s;
cin >> s;
string ans = "draw";
if(s[0] == s[1] && s[1] == s[2]) ans = s[0];
if(s[1] == s[2] && s[2] == s[3]) ans = s[1];
if(s[2] == s[3] && s[3] == s[4]) ans = s[2];
cout << ans << endl;
}
回答例 (Python)
S = input()
ans = "draw"
if S[0] == S[1] == S[2]:
ans = S[0]
if S[1] == S[2] == S[3]:
ans = S[1]
if S[2] == S[3] == S[4]:
ans = S[2]
print(ans)
posted:
last update: