結果

問題 No.24 数当てゲーム
ユーザー eto_nagisaeto_nagisa
提出日時 2017-12-07 05:04:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,864 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 153,832 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 10:58:11
合計ジャッジ時間 2,655 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi y, n;
	int f = 0;
	REP(i, N) {
		vi tmp(4);
		REP(j, 4)cin >> tmp[j];
		string s;
		cin >> s;
		if (s[0] == 'Y') {
			vi next;
			REP(j, y.size()) {
				REP(k, tmp.size()) {
					if (y[j] == tmp[k])next.push_back(y[j]);
				}
			}
			if (!f)y = tmp;
			else y = next;
			f = 1;
		}
		else {
			REP(j, 4)n.push_back(tmp[j]);
		}
	}
	sort(ALL(y)); sort(ALL(n));
	UNIQUE(y); UNIQUE(n);
	if (n.size() == 9) {
		REP(i, 10) {
			int f = 0;
			REP(j, 9) {
				if (n[j] == i)f = 1;
			}
			if (!f) {
				cout << i << endl;
				return 0;
			}
		}
	}
	REP(i, 10) {
		int c = lower_bound(ALL(y), i) - y.begin();
		if (c != y.size() && y[c] == i) {
			int d = lower_bound(ALL(n), i) - n.begin();
			if(d==n.size()||n[d]!=i){
				cout << i << endl;
				return 0;
			}
		}
	}
}
0