結果
| 問題 |
No.52 よくある文字列の問題
|
| コンテスト | |
| ユーザー |
TLwiegehtt
|
| 提出日時 | 2015-07-14 04:06:48 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 835 bytes |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 21,632 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 05:21:47 |
| 合計ジャッジ時間 | 894 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:55:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
55 | scanf("%s", s);
| ^~~~~~~~~~~~~~
ソースコード
#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