結果

問題 No.69 文字を自由に並び替え
コンテスト
ユーザー sasakki
提出日時 2016-05-21 00:46:28
言語 C90
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 486 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 178 ms
コンパイル使用メモリ 29,184 KB
最終ジャッジ日時 2026-02-23 21:19:17
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:10:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |   scanf("%s", str1);
      |   ^~~~~~~~~~~~~~~~~
main.c:11:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |   scanf("%s", str2);
      |   ^~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

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

int main(){
  
  char str1[256];
  char str2[256];
  int cnt[26] = {0};

  scanf("%s", str1);
  scanf("%s", str2);

  int i;
  for(i = 0; i < strlen(str1); i++){
    char c = str1[i];
    cnt[c-97]++;
  }

  for(i = 0; i < strlen(str2); i++){
    char c = str2[i];
    cnt[c-97]--;
  }

  for(i = 0; i < 26; i++){
    if(cnt[i] != 0){
      printf("NO\n");
      break;
    }
    else if(i == 25){
      printf("YES\n");
    }
  }

  return 0;
}
0