結果
| 問題 |
No.69 文字を自由に並び替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-14 19:23:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 683 bytes |
| コンパイル時間 | 392 ms |
| コンパイル使用メモリ | 45,952 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-14 06:59:40 |
| 合計ジャッジ時間 | 1,046 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%s",A);
| ~~~~~^~~~~~~~
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%s",B);
| ~~~~~^~~~~~~~
main.cpp:11:9: warning: ‘length’ may be used uninitialized in this function [-Wmaybe-uninitialized]
11 | int length;
| ^~~~~~
ソースコード
#include <stdio.h>
#include <map>
int main(){
//iuput
char A[10+1];
char B[10+1];
scanf("%s",A);
scanf("%s",B);
//string length
int length;
for (int i = 0;i < 10+1;i++){
if (A[i] == '\0'){
length = i;
break;
}
}
//create map
std::map<char,int> count_A;
std::map<char,int> count_B;
for (int i = 0;i < length;i++){
count_A[A[i]] = 0;
count_B[B[i]] = 0;
}
for (int i = 0;i < length;i++){
count_A[A[i]]++;
count_B[B[i]]++;
}
//output
if (count_A == count_B){
printf("YES\n");
}else{
printf("NO\n");
}
return 0;
}