結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 184184
提出日時 2015-05-08 23:12:07
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 863 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 40,192 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 13:14:12
合計ジャッジ時間 1,739 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 1 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         int d;char s1[1000],s2[1000];scanf("%d%s%s",&d,s1,s2);
      |                                      ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>



using namespace std;

int main(){
	int d;char s1[1000],s2[1000];scanf("%d%s%s",&d,s1,s2);
	strcat(s1,s2);int ans=0,len=strlen(s1);
	vector<int> v,vcnt;
	int cnt=0;
	v.push_back(-1);vcnt.push_back(0);
	for(int i=0;i<len;i++){
		if(s1[i]=='o'&&v[v.size()-1]==0)vcnt[v.size()-1]++;
		else if(s1[i]=='o'){v.push_back(0);vcnt.push_back(1);} 
		if(s1[i]=='x'&&v[v.size()-1]==1)vcnt[v.size()-1]++;
		else if(s1[i]=='x'){v.push_back(1);vcnt.push_back(1);} 
		if(v.size()>2&&v[v.size()-1]==0&&(i==len-1||s1[i+1]=='x')&&vcnt[v.size()-2]<=d){
			cnt=vcnt[v.size()-1]+min(vcnt[v.size()-2],d)+vcnt[v.size()-3];
			if(ans<cnt)ans=cnt;
			
			
		}
	}  
	for(int i=0;i<v.size();i++){
		if(v[i]==0){
			if(ans<vcnt[i]+d)ans=vcnt[i]+d;
		}
	}
	
	if(ans<d)ans=d;
	 
	printf("%d\n",ans);
	
	
	
	return 0;
}
0