結果

問題 No.69 文字を自由に並び替え
コンテスト
ユーザー goodbaton
提出日時 2014-11-23 16:16:04
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 596 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 490 ms
コンパイル使用メモリ 90,016 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-24 23:35:54
合計ジャッジ時間 1,836 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:21:12: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   21 |         ans++;
      |         ~~~^~
main.cpp:16:22: note: 'ans' was declared here
   16 |     char a[11],b[11],ans;
      |                      ^~~

ソースコード

diff #
raw source code

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;



int main(){
    char a[11],b[11],ans;
    
    scanf("%s%s",a,b);
    
    for(int i=0;b[i]!='\0';i++){
        ans++;
        for(int j=0;j<10;j++){
            if(a[j]==b[i]){
                a[j]=' ';
                ans--;
                break;
            }
        }
    }
    
    if(ans==0)
        puts("YES");
    else
        puts("NO");
    
    return 0;
}
0