結果

問題 No.110 しましまピラミッド
ユーザー QDSNQDSN
提出日時 2019-12-03 14:02:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 176 ms / 5,000 ms
コード長 2,417 bytes
コンパイル時間 1,503 ms
コンパイル使用メモリ 169,496 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 03:27:40
合計ジャッジ時間 7,002 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
4,376 KB
testcase_01 AC 127 ms
4,380 KB
testcase_02 AC 136 ms
4,376 KB
testcase_03 AC 129 ms
4,380 KB
testcase_04 AC 123 ms
4,376 KB
testcase_05 AC 142 ms
4,380 KB
testcase_06 AC 138 ms
4,380 KB
testcase_07 AC 129 ms
4,376 KB
testcase_08 AC 132 ms
4,376 KB
testcase_09 AC 155 ms
4,380 KB
testcase_10 AC 129 ms
4,376 KB
testcase_11 AC 135 ms
4,380 KB
testcase_12 AC 130 ms
4,380 KB
testcase_13 AC 128 ms
4,376 KB
testcase_14 AC 140 ms
4,376 KB
testcase_15 AC 127 ms
4,380 KB
testcase_16 AC 131 ms
4,376 KB
testcase_17 AC 164 ms
4,380 KB
testcase_18 AC 122 ms
4,376 KB
testcase_19 AC 147 ms
4,376 KB
testcase_20 AC 121 ms
4,376 KB
testcase_21 AC 130 ms
4,380 KB
testcase_22 AC 135 ms
4,376 KB
testcase_23 AC 149 ms
4,376 KB
testcase_24 AC 133 ms
4,376 KB
testcase_25 AC 139 ms
4,376 KB
testcase_26 AC 140 ms
4,376 KB
testcase_27 AC 176 ms
4,376 KB
testcase_28 AC 176 ms
4,380 KB
testcase_29 AC 174 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int nw, nb;
    cin >> nw;
    vector<int> w(nw);
    for(size_t i = 0; i < nw; i++) {
        cin >> w[i];
    }
    cin >> nb;
    vector<int> b(nb);
    for(size_t i = 0; i < nb; i++) {
        cin >> b[i];
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << 20); bit++) {
        int tans = 0;
        int t = bit;
        bool isW = true;
        vector<int> ww = w, bb = b;
        for(int j = 0; j < 20; j++) {
            if(t & 1) {
                if(isW) {
                    auto ex = find(all(ww), j + 1);
                    if(ex != ww.end()) {
                        tans++;
                        isW = false;
                        (*ex) = -1;
                    } else {
                        tans = -114514;
                        break;
                    }
                } else {
                    auto ex = find(all(bb), j + 1);
                    if(ex != bb.end()) {
                        tans++;
                        isW = true;
                        (*ex) = -1;
                    } else {
                        tans = -114514;
                        break;
                    }
                }
            }
            t = t >> 1;
        }
        ans = max(ans, tans);
    }
    for(int bit = 0; bit < (1 << 20); bit++) {
        int tans = 0;
        int t = bit;
        bool isW = false;
        vector<int> ww = w, bb = b;
        for(int j = 0; j < 20; j++) {
            if(t & 1) {
                if(isW) {
                    auto ex = find(all(ww), j + 1);
                    if(ex != ww.end()) {
                        tans++;
                        isW = false;
                        (*ex) = -1;
                    } else {
                        tans = -114514;
                        break;
                    }
                } else {
                    auto ex = find(all(bb), j + 1);
                    if(ex != bb.end()) {
                        tans++;
                        isW = true;
                        (*ex) = -1;
                    } else {
                        tans = -114514;
                        break;
                    }
                }
            }
            t = t >> 1;
        }
        ans = max(ans, tans);
    }
    cout << ans << endl;
}
0