답안 #1040635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1040635 2024-08-01T07:59:17 Z hotboy2703 카멜레온의 사랑 (JOI20_chameleon) C++17
0 / 100
1 ms 344 KB
#include "chameleon.h"

#include<bits/stdc++.h>
using ll = int;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
namespace {

int variable_example = 1;

}  // namespace
namespace MOMJOKES{
    const ll MAXN = 510*2;
    ll L[MAXN],R[MAXN];
    vector <ll> cand[MAXN];
    ll pf[MAXN];
    ll sf[MAXN];

}
void TLE(){
    ll i=0;
    while (i<=1e18)i++;
}
ll cnt = 0;
ll query(vector <ll> tmp){
    cnt++;
    // if (cnt>20000)exit(0);
    return Query(tmp);
}

void Solve(int n) {
    using namespace MOMJOKES;
    {
        vector <ll> tmp;
        for (ll i = 1;i <= n;i ++){
            tmp.push_back(i);
            pf[i] = query(tmp);
            ll l = 1,r = i - 1;
            while (l <= r){
                ll mid = (l + r) >> 1;
                vector <ll> cur;
                for (ll j = 1;j <= mid;j ++)cur.push_back(mid);
                cur.push_back(i);
                if (query(cur) <= pf[mid])r = mid - 1;
                else l = mid + 1;
            }
            if (r + 1 != i){
                cout<<r+1<<' '<<i<<'\n';
            }
        }
        return;
    }
    if (n <= 50){
        for (ll i = 1;i <= 2*n;i ++){
            for (ll j = i + 1;j <= 2*n;j ++){
                if (query({i,j}) == 1){
                    cand[i].push_back(j);
                    cand[j].push_back(i);
                }
            }
        }
    }
    else{
        for (ll i = n+1;i<=2*n;i++){
            auto add=[&](ll x,ll y){
                cand[x].push_back(y);
                cand[y].push_back(x);
            };
            ll ans_l,ans_r,ans_mid;
            {
                ll l = 1,r = n;
                while (l <= r){
                    ll mid = (l + r) >> 1;
                    vector <ll> tmp;
                    for (ll j = 1;j <= mid;j ++)tmp.push_back(j);
                    tmp.push_back(i);
                    ll cur = query(tmp);
                    if (cur<=mid){r = mid - 1;}
                    else l = mid + 1;
                }
                ans_l = r + 1;
            }
            {
                ll l = 1,r = n;
                while (l <= r){
                    ll mid = (l + r) >> 1;
                    vector <ll> tmp;
                    for (ll j = mid;j <= n;j ++)tmp.push_back(j);
                    tmp.push_back(i);
                    ll cur = query(tmp);
                    if (cur<=n-mid+1){l = mid + 1;}
                    else r = mid - 1;
                }
                ans_r = l - 1;
            }
            if (ans_l != ans_r){
                ll l = ans_l + 1,r = ans_r - 1;
                while (l <= r){
                    ll mid = (l + r) >> 1;
                    vector <ll> tmp;
                    for (ll j = ans_l+1;j <= mid;j ++)tmp.push_back(j);
                    ll cur1 = query(tmp);
                    tmp.push_back(i);
                    ll cur2 = query(tmp);
                    if (cur2<=cur1){r = mid - 1;}
                    else l = mid + 1;
                }
                ans_mid = r + 1;
                add(i,ans_l);
                add(i,ans_mid);
                add(i,ans_r);
            }
            else{
                add(i,ans_l);
            }
        }
        if (cnt>18000)assert(0);
    }
    set <pll> s;
    for (ll i = 1;i <= 2 * n;i ++){
        if (sz(cand[i]) == 3){
            for (ll j = 0;j < 3;j ++){
                vector <ll> all = {i};
                for (ll j1 = 0;j1 < 3;j1 ++){
                    if (j1 != j)all.push_back(cand[i][j1]);
                }
                if (j == 2 || query(all) == 1){
                    L[i] = cand[i][j];
                    break; 
                }
            }
        }
        else{
            ll u = i,v = cand[i][0];
            if (u > v)swap(u,v);
            s.insert(MP(u,v));
        }
    }    
    for (ll i = 1;i <= 2 * n;i ++){
        if (sz(cand[i]) == 3){
            for (ll j = 0;j < 3;j ++){
                if (cand[i][j] == L[i] || L[cand[i][j]] == i)continue;
                ll u = i,v = cand[i][j];
                if (u > v)swap(u,v);
                s.insert(MP(u,v));
            }
        }
    }   
    for (auto x:s)Answer(x.fi,x.se);
}

Compilation message

chameleon.cpp:15:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
   15 | int variable_example = 1;
      |     ^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -