結果

問題 No.69 文字を自由に並び替え
ユーザー ococonomy1ococonomy1
提出日時 2018-09-08 13:32:41
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 822 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 29,112 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-21 00:08:14
合計ジャッジ時間 1,057 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int stringsoat(char a[]){
  int length;
  for(int i = 0; i < 13; i++){
    if(a[i] == '\0'){
      length = i;
      break;
    }
  }

  for(int i = 0; i < length; i++){
    int max = 0,maxpoint;
    for(int j = i; j < length; j++){
      if(max < a[j]){
        max = a[j];
        maxpoint = j;
      }
    }
    char swap = a[i];
    a[i] = a[maxpoint];
    a[maxpoint] = swap;
  }
  return length;
}

int main(void){
  char a[12],b[12],lengthA,lengthB,checker = 1;
  fgets(a,sizeof(a),stdin);
  fgets(b,sizeof(b),stdin);
  lengthA = stringsoat(a);
  lengthB = stringsoat(b);

  for(int i = 0; i < lengthA; i++){
    if(lengthA != lengthB)break;
    if(a[i] != b[i])break;
    if(i == lengthA - 1){
      checker = 0;
    }
  }
  if(checker == 1)printf("NO\n");
  else printf("YES\n");
  return 0;
}
0