Submission #405536

# Submission time Handle Problem Language Result Execution time Memory
405536 2021-05-16T14:10:34 Z Victor Chameleon's Love (JOI20_chameleon) C++17
44 / 100
19 ms 380 KB
#include "chameleon.h"

#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;

const int INF = 1'000'000'007;

bitset<1001> taken;

void bsearch(vi chams, int cham) {
    if (sz(chams) == 1) {
        taken[chams[0] - 1] = 1;
        Answer(cham, chams[0]);
        return;
    }

    int si = sz(chams);
    vi next(si >> 1);
    rep(i, 0, si >> 1) next[i] = chams[i];

    int c1 = Query(next);
    next.pb(cham);
    int c2 = Query(next);

    if (c1 == c2)
        next.pop_back();

    else {
        next.clear();
        rep(i, si >> 1, si) next.pb(chams[i]);
    }

    bsearch(next, cham);
}

void Solve(int n) {
    int like[n * 2 + 1];

    if (n <= 50) {
        vvi allcands(n * 2 + 1);

        rep(i, 1, n*2+1) {
            vi qvec, &cands = allcands[i];
            qvec.pb(i);

            rep(j, 1, n * 2 + 1) {
                if (i == j) continue;
                qvec.pb(j);
                int colors = Query(qvec);
                qvec.pop_back();
                if (colors == 1) cands.pb(j);
            }

            if (sz(cands) != 1) {
                rep(mask, 3, 7) {
                    if (mask == 4) continue;
                    rep(j, 0, 3) if (mask & (1 << j)) qvec.pb(cands[j]);

                    if (Query(qvec) == 1) {
                        rep(j, 0, 3) if (!(mask & (1 << j))) {
                            like[i] = cands[j];
                            cands.erase(cands.begin() + j);
                        }
                        break;
                    }

                    qvec.pop_back();
                    qvec.pop_back();
                }
            }
        }
        
        rep(i, 1, n * 2 + 1) {
            if (taken[i]) continue;
            vi &cands = allcands[i];
            int same = cands[0];
            if (sz(cands) == 2 && like[same] == i)
                same = cands[1];

            Answer(i, same);
            taken[same] = 1;
        }
    }

    else
        rep(i, 0, n * 2) {
            if (taken[i]) continue;
            taken[i] = 1;
            vi vec;
            rep(j, 0, n * 2) if (!taken[j]) vec.pb(j + 1);
            bsearch(vec, i + 1);
        }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 19 ms 380 KB Output is correct
4 Correct 19 ms 356 KB Output is correct
5 Correct 17 ms 376 KB Output is correct
6 Correct 16 ms 368 KB Output is correct
7 Correct 19 ms 328 KB Output is correct
8 Correct 16 ms 328 KB Output is correct
9 Correct 17 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 3 ms 200 KB Output is correct
11 Correct 3 ms 200 KB Output is correct
12 Correct 3 ms 200 KB Output is correct
13 Correct 3 ms 200 KB Output is correct
14 Correct 3 ms 200 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
16 Correct 3 ms 200 KB Output is correct
17 Correct 3 ms 200 KB Output is correct
18 Correct 3 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Incorrect 1 ms 328 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 19 ms 380 KB Output is correct
4 Correct 19 ms 356 KB Output is correct
5 Correct 17 ms 376 KB Output is correct
6 Correct 16 ms 368 KB Output is correct
7 Correct 19 ms 328 KB Output is correct
8 Correct 16 ms 328 KB Output is correct
9 Correct 17 ms 344 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 200 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 1 ms 200 KB Output is correct
17 Correct 1 ms 200 KB Output is correct
18 Correct 1 ms 200 KB Output is correct
19 Correct 3 ms 200 KB Output is correct
20 Correct 3 ms 200 KB Output is correct
21 Correct 3 ms 200 KB Output is correct
22 Correct 3 ms 200 KB Output is correct
23 Correct 3 ms 200 KB Output is correct
24 Correct 3 ms 200 KB Output is correct
25 Correct 3 ms 200 KB Output is correct
26 Correct 3 ms 200 KB Output is correct
27 Correct 3 ms 200 KB Output is correct
28 Correct 1 ms 200 KB Output is correct
29 Correct 1 ms 200 KB Output is correct
30 Incorrect 1 ms 328 KB Wrong Answer [6]
31 Halted 0 ms 0 KB -