結果
| 問題 | No.52 よくある文字列の問題 |
| コンテスト | |
| ユーザー |
TLwiegehtt
|
| 提出日時 | 2015-07-14 04:06:48 |
| 言語 | C(gnu17) (gcc 15.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 835 bytes |
| 記録 | |
| コンパイル時間 | 351 ms |
| コンパイル使用メモリ | 38,356 KB |
| 最終ジャッジ日時 | 2026-02-23 18:43:08 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
ソースコード
#include <stdio.h>
#include <string.h>
int stPos;
int memoPos;
char memo[1000][15];
char stack[15];
int saiki(char *str, int s, int g){
int i;
int ret = 0;
if( s == g ){
int noHit = 1;
stack[stPos] = str[s];
stack[stPos+1] = '\0';
for(i=0;i<memoPos;i++){
if(strcmp(memo[i], stack) == 0 ){
noHit = 0;
break;
}
}
if(noHit){
// printf("%d %d %s\n", s, g, stack);
strcpy(memo[memoPos], stack);
memoPos += 1;
return 1;
}
return 0;
}
stack[stPos] = str[s];
stPos++;
stack[stPos] = '\0';
ret = ret + saiki(str,s+1,g);
stPos--;
stack[stPos] = str[g];
stPos++;
stack[stPos] = '\0';
ret = ret + saiki(str,s,g-1);
stPos--;
return ret;
}
int main(void){
int cnt;
char s[15];
scanf("%s", s);
cnt = saiki(s, 0, strlen(s)-1);
printf("%d\n", cnt);
return 0;
}
TLwiegehtt