結果

問題 No.24 数当てゲーム
ユーザー daku9640daku9640
提出日時 2016-11-21 08:54:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 3,854 bytes
コンパイル時間 1,902 ms
コンパイル使用メモリ 177,880 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 12:14:07
合計ジャッジ時間 3,043 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 RE -
testcase_03 AC 2 ms
5,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n; cin >> n;
    int a, b, c, d;
    string r;
//    set<int> set_y, set_n, set_temp;
    set<int> set_y, set_n;
    set<int> set_all = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

    rep(i, n) {
    	cin >> a >> b >> c >> d >> r;
    	if (r == "NO") {
//    		set<int> set_temp {a, b, c, d};
    		set_n.insert(a);
    		set_n.insert(b);
    		set_n.insert(c);
    		set_n.insert(d);

    		if(set_n.size() == 9)
    			repi(i, 9)
    				if (set_n.find(i) == set_n.end()) {
    					P(i);
    					return 0;
    				}
    		if(set_y.size() != 0)
    			for(int s: set_y)
    				if (set_n.find(s) != set_n.end())
    					set_y.erase(s);
    		if(set_y.size() == 1)
    			for(int s: set_y) {
    				P(s);
    				return 0;
    			}
    	} else {
    		if(set_y.size() == 0) {
    			set_y.insert(a);
    			set_y.insert(b);
    			set_y.insert(c);
    			set_y.insert(d);
    		} else {
//    			set_y.erase(a);
//    			set_y.erase(b);
//    			set_y.erase(c);
//    			set_y.erase(d);
//    			if(set_y.size() == 1) {
//    				for(int s: set_y) {
//        				P(s);
//        				return 0;
//    				}
//    			}
//    			int cnt = 0, j;
    			set<int> set_temp;
    			for(int s: {a, b, c, d})
    				if (set_y.find(s) != set_y.end()) {
    					set_temp.insert(s);
    				}
    			set_y = set_temp;
    		}
    		if(set_n.size() != 0) {
    			for(int s: set_y) {
    				if (set_n.find(s) != set_n.end())
    					set_y.erase(s);
    			}
    		}
    		if(set_y.size() == 1) {
    			for(int s: set_y) {
    				P(s);
    				return 0;
    			}
    		}
//    			if (cnt == 1) {
//    				P(j);
//    				return 0;
//    			}
//    			int cnt = 0, j;
//    			for(int s: {a, b, c, d})
//    				if (set_y.find(s) != set_y.end()) {
//    					++cnt;
//    					j = s;
//    				}
//    			if (cnt == 1) {
//    				P(j);
//    				return 0;
//    			}

    	}
    }


    return 0;
}
0