結果

問題 No.232 めぐるはめぐる (2)
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-02-29 00:26:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 991 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 63,660 KB
実行使用メモリ 6,772 KB
最終ジャッジ日時 2023-10-24 18:57:39
合計ジャッジ時間 2,556 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
6,772 KB
testcase_01 AC 131 ms
6,772 KB
testcase_02 AC 131 ms
6,772 KB
testcase_03 AC 131 ms
6,772 KB
testcase_04 AC 5 ms
6,772 KB
testcase_05 AC 3 ms
6,772 KB
testcase_06 AC 3 ms
6,772 KB
testcase_07 AC 4 ms
6,772 KB
testcase_08 AC 94 ms
6,772 KB
testcase_09 AC 4 ms
6,772 KB
testcase_10 AC 3 ms
6,772 KB
testcase_11 WA -
testcase_12 AC 4 ms
6,772 KB
testcase_13 AC 3 ms
6,772 KB
testcase_14 WA -
testcase_15 AC 3 ms
6,772 KB
testcase_16 AC 3 ms
6,772 KB
testcase_17 AC 3 ms
6,772 KB
testcase_18 AC 5 ms
6,772 KB
testcase_19 WA -
testcase_20 AC 4 ms
6,772 KB
testcase_21 AC 4 ms
6,772 KB
testcase_22 AC 3 ms
6,772 KB
testcase_23 AC 3 ms
6,772 KB
testcase_24 AC 3 ms
6,772 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:26:41: warning: multi-character character constant [-Wmultichar]
   26 |                         if(A>0) AB[i++]='^>',AB[i++]='<',A--;
      |                                         ^~~~
main.cpp:27:46: warning: multi-character character constant [-Wmultichar]
   27 |                         else if(A<0) AB[i++]='v>',AB[i++]='<',A++;
      |                                              ^~~~
main.cpp:28:46: warning: multi-character character constant [-Wmultichar]
   28 |                         else if(B>0) AB[i++]='>v',AB[i++]='^',B--;
      |                                              ^~~~
main.cpp:29:38: warning: multi-character character constant [-Wmultichar]
   29 |                         else AB[i++]='<v',AB[i++]='^',B++;
      |                                      ^~~~
main.cpp: In function ‘int main()’:
main.cpp:26:41: warning: overflow in conversion from ‘int’ to ‘char’ changes value from ‘24126’ to ‘'>'’ [-Woverflow]
   26 |                         if(A>0) AB[i++]='^>',AB[i++]='<',A--;
      |                                         ^~~~
main.cpp:27:46: warning: overflow in conversion from ‘int’ to ‘char’ changes value from ‘30270’ to ‘'>'’ [-Woverflow]
   27 |                         else if(A<0) AB[i++]='v>',AB[i++]='<',A++;
      |                                              ^~~~
main.cpp:28:46: warning: overflow in conversion from ‘int’ to ‘char’ changes value from ‘15990’ to ‘'v'’ [-Woverflow]
   28 |                         else if(B>0) AB[i++]='>v',AB[i++]='^',B--;
      |                                              ^~~~
main.cpp:29:38: warning: overflow in conversion from ‘int’ to ‘char’ changes value from ‘15478’ to ‘'v'’ [-Woverflow]
   29 |                         else AB[i++]='<v',AB[i++]='^',B++;
      |                                      ^~~~

ソースコード

diff #

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

using namespace std;

#define TMAX 100000

int main(){

	int T,A,B;
	string AB[TMAX];

	cin>>T>>A>>B;

	for(int i=0;i<T;i++){
		AB[i]="";
		
		if(T-i==2&&abs(A)==1&&abs(B)==1){
			if(A>0) AB[i++]='^',A--;
			else AB[i++]='v',A++;
			if(B>0) AB[i++]='>',B--;
			else AB[i++]='<',B++;
		}
		else if(T-i==2&&abs(A)+abs(B)==1){
			if(A>0) AB[i++]='^>',AB[i++]='<',A--;
			else if(A<0) AB[i++]='v>',AB[i++]='<',A++;
			else if(B>0) AB[i++]='>v',AB[i++]='^',B--;
			else AB[i++]='<v',AB[i++]='^',B++;
			
		}
		else if(A==0&&B==0){
			if(T-i==2){
				AB[i++]="<";
				AB[i++]=">";
			}
			else if(T-i==3){
				AB[i++]="<^";
				AB[i++]=">";
				AB[i++]="v";
			}
			else AB[i]+='>',B--;
		}
		else{
			if(A>0) AB[i]+='^',A--;
			else if(A!=0) AB[i]+='v',A++;
			if(B>0) AB[i]+='>',B--;
			else if(B!=0) AB[i]+='<',B++;
		}
	}

	if(A==0&&B==0){
		cout<<"YES"<<endl;
		for(int i=0;i<T;i++){
			cout<<AB[i]<<endl;
		}
	}
	else cout<<"NO"<<endl;

}
0