結果
| 問題 | No.69 文字を自由に並び替え | 
| コンテスト | |
| ユーザー |  sasa | 
| 提出日時 | 2025-03-04 09:38:37 | 
| 言語 | C (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 635 bytes | 
| コンパイル時間 | 518 ms | 
| コンパイル使用メモリ | 23,808 KB | 
| 実行使用メモリ | 8,604 KB | 
| 最終ジャッジ日時 | 2025-03-04 09:38:39 | 
| 合計ジャッジ時間 | 1,650 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 15 | 
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:22: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
    5 |         char *strA = malloc(11);
      |                      ^~~~~~
main.c:2:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | 
main.c:5:22: warning: incompatible implicit declaration of built-in function ‘malloc’ [-Wbuiltin-declaration-mismatch]
    5 |         char *strA = malloc(11);
      |                      ^~~~~~
main.c:5:22: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
main.c:7:19: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
    7 |         int lena =strlen(strA);
      |                   ^~~~~~
main.c:2:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
    1 | #include <stdio.h>
  +++ |+#include <string.h>
    2 | 
main.c:7:19: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
    7 |         int lena =strlen(strA);
      |                   ^~~~~~
main.c:7:19: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%s",strA);
      |         ^~~~~~~~~~~~~~~~
main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%s",strB);
      |         ^~~~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
int main(void){
	// 文字列Aをスキャン・ポインタ
	char *strA = malloc(11);
	scanf("%s",strA);
	int lena =strlen(strA);
	char *a = strA;
	// 文字列Bをスキャン・ポインタ
	char *strB = malloc(11);
	scanf("%s",strB);
	int lenb = strlen(strB);
	char *b = strB;
	int count = 0;
	int ans = 0;
	for(int i = 0;i < lena;i++){
		count = 0;
		for(int j = 0;j < lenb;j++){
			//printf("A:%c B:%c\n",a[i],b[j]);
			if(a[i] == b[j]){
				b[j] = '0';
				count++;
				break;
			}
		}
		if(count == 0){
			printf("NO");
			break;
		}
		else{
			ans++;
		}
	}
	if(ans == lenb){
		printf("YES");
	}
	
	
}
            
            
            
        