結果

問題 No.197 手品
コンテスト
ユーザー kongarishisyamo
提出日時 2016-02-24 18:09:33
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 863 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 411 ms
コンパイル使用メモリ 79,344 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-15 10:48:08
合計ジャッジ時間 1,485 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:46:36: warning: 'bloc' may be used uninitialized [-Wmaybe-uninitialized]
   46 |                         N-=abs(aloc-bloc);
      |                                ~~~~^~~~~
main.cpp:11:13: note: 'bloc' was declared here
   11 |         int bloc,aloc;
      |             ^~~~
main.cpp:46:36: warning: 'aloc' may be used uninitialized [-Wmaybe-uninitialized]
   46 |                         N-=abs(aloc-bloc);
      |                                ~~~~^~~~~
main.cpp:11:18: note: 'aloc' was declared here
   11 |         int bloc,aloc;
      |                  ^~~~

ソースコード

diff #
raw source code

#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main(){

	string Sb,Sa;
	long long N;
	int bloc,aloc;
	int bmaru=0,bbatu=0,amaru=0,abatu=0;
	cin>>Sb;
	cin>>N;
	cin>>Sa;

	if(Sb=="ooo"){
		if(Sa=="ooo") cout<<"FAILURE"<<endl;
		else cout<<"SUCCESS"<<endl;
	}
	else if(Sb=="xxx"){
		if(Sa=="xxx") cout<<"FAILURE"<<endl;
		else cout<<"SUCCESS"<<endl;
	}
	else{
		for(int i=0;i<3;i++){
			if(Sb[i]=='o') bmaru++;
			else bbatu++;
			if(Sa[i]=='o') amaru++;
			else abatu++;
		}
		if(amaru!=bmaru) cout<<"SUCCESS"<<endl;
		else{
			if(bmaru==1){
				for(int i=0;i<3;i++){
					if(Sb[i]=='o') bloc=i;
					if(Sa[i]=='o') aloc=i;
				}
			}
			else{
				for(int i=0;i<3;i++){
					if(Sb[i]=='x') bloc=i;
					if(Sa[i]=='x') aloc=i;
				}
			}
			N-=abs(aloc-bloc);
			if(N>=0) cout<<"FAILURE"<<endl;
			else cout<<"SUCCESS"<<endl;
		}
	}
}
0