結果

問題 No.52 よくある文字列の問題
ユーザー akakimidoriakakimidori
提出日時 2017-06-20 22:21:24
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 675 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 21,560 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 04:09:20
合計ジャッジ時間 837 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 0 ms
4,348 KB
testcase_03 AC 0 ms
4,348 KB
testcase_04 AC 7 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 7 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 0 ms
4,348 KB
testcase_09 AC 0 ms
4,348 KB
testcase_10 AC 0 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:17:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |   scanf("%s",s);
      |   ^~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

void build(char *s,int len,char *res,int bit){
  int l=0;
  int r=len-1;
  int i=0;
  while(l<r){
    res[i++]=((bit&0x01)?s[r--]:s[l++]);
    bit>>=1;
  }
  res[i]=s[l];
  return;
}

void run(void){
  char s[11];
  scanf("%s",s);

  int len=0;
  while(s[len]!='\0') len++;

  int ans=1<<(len-1);
  int i,j;
  for(i=0;i<(1<<(len-1));i++){
    char si[11];
    build(s,len,si,i);
    for(j=i+1;j<(1<<(len-1));j++){
      char sj[11];
      build(s,len,sj,j);
      int k;
      for(k=0;k<len;k++){
	if(si[k]!=sj[k]) break;
      }
      if(k==len){
	ans--;
	break;
      }
    }
  }
  printf("%d\n",ans);
  return;
}

int main(void){
  run();
  return 0;
}
0