제출 #1339817

#제출 시각아이디문제언어결과실행 시간메모리
1339817Andrey카멜레온의 사랑 (JOI20_chameleon)C++20
100 / 100
29 ms5180 KiB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;

int n;
bool bruh[1001][1001];
int yeah[1001][1001];

void Solve(int N) {
    n = N;
    vector<int> wut[4];
    for(int i = 1; i <= 2*n; i++) {
        int p = -1;
        for(int j = 0; j < 4; j++) {
            vector<int> wow = wut[j];
            wow.push_back(i);
            if(Query(wow) < wow.size()) {
                int y = 0;
                while(y < wut[j].size()) {
                    vector<int> idk(0);
                    int l = y,r = wut[j].size()-1;
                    while(l < r) {
                        vector<int> idk(0);
                        int mid = (l+r+1)/2;
                        for(int z = l; z < mid; z++) {
                            idk.push_back(wut[j][z]);
                        }
                        idk.push_back(i);
                        if(Query(idk) < idk.size()) {
                            r = mid-1;
                        }
                        else {
                            l = mid;
                        }
                    }
                    bruh[i][wut[j][l]] = true;
                    bruh[wut[j][l]][i] = true;
                    y = l+1;
                    vector<int> troll(0);
                    for(int i = y; i < wut[j].size(); i++) {
                        troll.push_back(wut[j][i]);
                    }
                    troll.push_back(i);
                    if(Query(troll) == troll.size()) {
                        break;
                    }
                }
            }
            else {
                p = j;
            }
        }
        wut[p].push_back(i);
    }
    for(int i = 1; i <= 2*n; i++) {
        vector<int> yo(0);
        for(int j = 1; j <= 2*n; j++) {
            if(bruh[i][j]) {
                yo.push_back(j);
            }
        }
        if(yo.size() == 1) {
            yeah[i][yo[0]]++;
        }
        else if(yo.size() == 2) {
            yeah[i][yo[0]]++;
            yeah[i][yo[1]]++;
        }
        else {
            if(Query({yo[0],yo[1],i}) == 1) {
                yeah[i][yo[0]]++;
                yeah[i][yo[1]]++;
            }
            else if(Query({yo[1],yo[2],i}) == 1) {
                yeah[i][yo[1]]++;
                yeah[i][yo[2]]++;
            }
            else {
                yeah[i][yo[0]]++;
                yeah[i][yo[2]]++;
            }
        }
    }
    for(int i = 1; i <= 2*n; i++) {
        for(int j = i+1; j <= 2*n; j++) {
            if(yeah[i][j]+yeah[j][i] >= 2) {
                Answer(i,j);
            }
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...