結果

問題 No.486 3 Straight Win(3連勝)
ユーザー Bantako
提出日時 2017-07-11 20:22:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 380 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 24,064 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 04:30:25
合計ジャッジ時間 1,070 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    3 | main(){
      | ^~~~
main.cpp: In function ‘int main()’:
main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     scanf("%s",S);
      |     ~~~~~^~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
main(){
    char S[101];
    scanf("%s",S);
    int n = 0;
    for(int i = 0;S[i] != '\0';i++){
        int flag = S[i]=='O'?1:-1;
        if(!n){n += flag;}
        else if(abs(n)>2){break;}
        else{
            if(n*flag>0){n += flag;}
            else{n=flag;}
        }
    }
    n /= 3;
    printf("%s\n",n?n>0?"East":"West":"NA");
}
0