結果

問題 No.547 未知の言語
コンテスト
ユーザー Ronlynes
提出日時 2017-07-28 22:26:28
言語 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  
実行時間 -
コード長 687 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 535 ms
コンパイル使用メモリ 92,396 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-12 14:47:09
合計ジャッジ時間 1,295 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:56,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
                 from main.cpp:1:
In member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]',
    inlined from 'std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:4372:61,
    inlined from 'int main()' at main.cpp:33:19:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/basic_string.h:1165:19: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
 1165 |         size_type __sz = _M_string_length;
      |                   ^~~~
main.cpp: In function 'int main()':
main.cpp:12:9: note: 'ans' was declared here
   12 |     int ans;
      |         ^~~

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main(void){
    int n;
    int ans;
    string s1[20], s2[20];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s1[i];
    }
    for(int i=0;i<n;i++){
        cin >> s2[i];
    }
    
    for(int i=0;i<n;i++){
        if(s1[i].length() != s2[i].length()){
            ans = i;
        }else{
            for(int j=0;j<s1[i].length();j++){
                if(s1[i][j] != s2[i][j]){
                    ans = i;
                }
            }
        }
    }
    cout << s1[ans] << endl;
    cout << s2[ans] << endl;
    return 0;
}
0