#include #include #include 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; }