답안 #617148

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
617148 2022-08-01T09:03:04 Z 박상훈(#8502) 카멜레온의 사랑 (JOI20_chameleon) C++17
0 / 100
54 ms 464 KB
#include "chameleon.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

namespace {

int n, qcnt;
bool chk[1010];
vector<int> a, adj[1010];

bool myquery(int l, int r, vector<int> v){
    assert(++qcnt<=47000);
    vector<int> Q = v;
    for (int i=l;i<=r;i++) Q.push_back(i);
    return Query(Q)!=(int)Q.size();
}

}  // namespace



void Solve(int N) {
    n = N;
    for (int i=0;i<=n*2;i++) a.push_back(i);

    for (int i=1;i<=n;i++){
        int prv = n;
        while(true){
            int l = prv+1, r = n*2-1, idx = n*2;
            if (!myquery(l, n*2, {i})) break;

            while(l<=r){
                int m = (l+r)>>1;
                if (myquery(prv+1, m, {i})) r = m-1, idx = m;
                else l = m+1;
            }

            assert(Query({i, idx})==1);
            adj[i].push_back(idx);
            prv = idx;
        }

        /*printf("%d: ", i);
        for (auto &x:adj[i]) printf("%d ", x);
        printf("\n");*/
    }

    for (int i=n+1;i<=n*2;i++){
        int prv = n+1;
        while(true){
            int l = 2, r = prv-1, idx = 1;
            if (!myquery(1, r, {i})) break;

            while(l<=r){
                int m = (l+r)>>1;
                if (myquery(m, prv-1, {i})) l = m+1, idx = m;
                else r = m-1;
            }

            assert(Query({i, idx})==1);
            adj[i].push_back(idx);
            prv = idx;
        }

        /*printf("%d: ", i);
        for (auto &x:adj[i]) printf("%d ", x);
        printf("\n");*/
    }

    /*for (int i=1;i<=n*2;i++){
        for (int j=i+1;j<=n*2;j++){
            if (Query({i, j})==1){
                adj[i].push_back(j);
                adj[j].push_back(i);
            }
        }
    }*/

    for (int i=1;i<=n*2;i++) if (adj[i].size()!=1){
        assert(adj[i].size()==3);

        for (int k=0;k<3;k++){
            vector<int> tmp = {i};
            for (int l=0;l<3;l++) if (k!=l) tmp.push_back(adj[i][l]);
            if (Query(tmp)==1){
                adj[i].erase(adj[i].begin()+k);
                break;
            }
        }
    }

    for (int i=1;i<=n*2;i++) if (!chk[i]){
        for (int k=0;k<(int)adj[i].size();k++){
            int v = adj[i][k];
            if (find(adj[v].begin(), adj[v].end(), i)==adj[v].end()) continue;
            Answer(i, v);
            chk[i] = 1, chk[v] = 1;
        }
        assert(chk[i]);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Runtime error 2 ms 464 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Runtime error 1 ms 464 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Runtime error 1 ms 464 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 54 ms 348 KB Wrong Answer [3]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Runtime error 2 ms 464 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -