結果

問題 No.304 鍵(1)
ユーザー magmag
提出日時 2020-09-14 07:48:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,137 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 68,184 KB
実行使用メモリ 24,456 KB
平均クエリ数 1.00
最終ジャッジ日時 2023-09-24 06:39:04
合計ジャッジ時間 3,137 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;

string input(istream& is){
    string ret;
    getline(is, ret);         //回答コードから受け取った文字列
    assert(ret.size() == 3);  //長さは 3
    for(char c : ret){        //数字のみかチェック
        assert('0' <= c && c <= '9');
    }
    return ret;
}

int main(int argc, char* argv[]){
    ifstream ifs(argv[1]);
    string ans = input(ifs);     //第一引数のファイルから正解の文字列を取得
    cerr << "Answer : " << ans << endl;

    while(1){
        string in = input(cin);  //標準入力から回答の文字列を取得
        if(in == ans){           //正解なら "unlocked" を出力して終了
            cout << "unlocked" << endl;
            if(getline(cin,in)){  //余計な出力がないか確認
                cerr << "Wrong Answer : too many outputs, \"" << in << "\"" << endl;
                abort();
            }
            return 0;
        }else{                   //不正解なら "locked" を出力
            cout << "locked" << endl;
        }
    }
    return 0;
}
0