結果

問題 No.24 数当てゲーム
ユーザー xuzijian629xuzijian629
提出日時 2018-09-13 22:27:56
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,656 bytes
コンパイル時間 818 ms
コンパイル使用メモリ 102,652 KB
実行使用メモリ 813,488 KB
最終ジャッジ日時 2023-09-13 19:59:34
合計ジャッジ時間 5,822 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <chrono>
#include <random>
#include <iterator>
#include <functional>
#include <utility>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

int main() {
    int n;
    cin >> n;
    multiset<int> yes, no;
    for (int i = 1; i < 10; i++) {
        yes.insert(i);
    }
    for (int i = 0; i < n; i++) {
        multiset<int> tmp;
        for (int i = 0; i < 4; i++) {
            int a;
            cin >> a;
            tmp.insert(a);
        }
        string s;
        cin >> s;
        if (s == "YES") {
            set_intersection(yes.begin(), yes.end(), tmp.begin(), tmp.end(), inserter(yes, yes.end()));
        } else {
            set_union(no.begin(), no.end(), tmp.begin(), tmp.end(), inserter(no, no.end()));
        }
    }
    
    if (yes.size() == 1) {
        cout << *(yes.begin()) << endl;
        return 0;
    }
    if (yes.size()) {
        for (int y: yes) {
            if (no.count(y) == 0) {
                cout << y << endl;
                return 0;
            }
        }
    }
    for (int i = 1; i < 10; i++) {
        if (no.count(i) == 0) {
            cout << i << endl;
        }
    }
}
0