結果

問題 No.457 (^^*)
ユーザー suppy193suppy193
提出日時 2017-01-11 14:36:06
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,451 bytes
コンパイル時間 1,029 ms
コンパイル使用メモリ 25,592 KB
実行使用メモリ 6,248 KB
最終ジャッジ日時 2023-08-23 08:28:22
合計ジャッジ時間 5,648 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 131 ms
4,376 KB
testcase_08 AC 698 ms
4,376 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int func(char s[], char face[])
{
	int i, j;
	int memo[10001][5] = {0};
	
	if(s[0] == face[0]){
		memo[0][0] = 1;
	}
	for(i = 1;i < strlen(s);i++){
		memo[i][0] = memo[i - 1][0];
		if(s[i] == face[0]){
			memo[i][0]++;
		}
	}
	for(i = 1;i < strlen(s);i++){
		if(s[i] == face[0]){
			//memo[i][0]++;
		}
		for(j = 1;j < strlen(face);j++){
			if(s[i] == face[j]){
				memo[i][j] = memo[i - 1][j] + memo[i - 1][j - 1];
			}
			else{
				memo[i][j] = memo[i - 1][j];
			}
		}
	}
	//for(i = 1;i < strlen(s);i++){
	//	printf("%d ", memo[i][strlen(face) - 1]);
	//}
	
	if(memo[strlen(s) - 1][strlen(face) - 1] > 0){
		return 1;
	}
	else{
		return 0;
	}
}


int main(void) {
	char s[10001], s_sub[10001] = {0};
	char face_l[] = "^^*";
	char face_r[] = "*^^";
	int memo[10001][5] = {0};
	int i, j, k, l;
	int count_l = 0;
	int count_r = 0;
	scanf("%s", s);
	//printf("%s\n", s);
	for(i = 0;i < strlen(s) - 1;i++){
		if(s[i] == '('){
			for(j = strlen(s);j > 0;j--){
				if(s[j] == ')'){
					//printf("%d %d\n", i, j);
					l = 0;
					for(k = i + 1;k < j;k++){
						s_sub[l] = s[k];
						l++;
						//printf("%c", s[k]);
					}
					s_sub[l] = '\0';
					//printf("\n");
					//printf("%s\n", s_sub);
					//printf("%d\n", func(s_sub, face_l));
					//printf("\n");
					count_l += func(s_sub, face_l);
					count_r += func(s_sub, face_r);
					
				}
			}
		}
	}

	printf("%d %d\n", count_l, count_r);

	return 0;
}
0