답안 #935249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935249 2024-02-29T01:22:53 Z 1075508020060209tc 카멜레온의 사랑 (JOI20_chameleon) C++14
40 / 100
33 ms 600 KB
#include "chameleon.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;

int n;
int vis[2010];
int love[2010];
vector<int>e[2010];
int lvlv[2010];
int slv(int a,vector<int>vc){
if(Query({a,vc[0],vc[1]})==1){
    return vc[2];
}
if(Query({a,vc[0],vc[2]})==1){
    return vc[1];
}
return vc[0];
}
int ask(int l,int r,vector<int>&vc){
for(int i=l;i<=r;i++){
    vc.push_back(i);
}
return Query(vc);
}
int ans[2010];
int dgr[2010];

void slvv(){
for(int i=1;i<=n;i++){
    if(e[i].size()==1){
        lvlv[i]=1;
        dgr[e[i][0]]++;
    }
}
for(int i=1;i<=n;i++){
    if(dgr[n+i]==1){
        lvlv[n+i]=1;
    }
}


}


void Solve(int N) {
n=N;
if(n<=50){
for(int i=1;i<=n*2;i++){
    for(int j=i+1;j<=n*2;j++){
        if(Query({i,j})==1){
            e[i].push_back(j);
            e[j].push_back(i);
        }
    }
}
}else{
for(int i=1;i<=n;i++){
    int l;int r;
    l=n+1;r=n*2+1;
    while(l<r){
        int mi=l+(r-l)/2;
        vector<int>vc;
        vc={i};
        if((mi==n*2+1)||ask(n+1,mi,vc)!=(mi-(n+1)+1)){
            r=mi;
        }else{
            l=mi+1;
        }
    }
    e[i].push_back(l);
    l++;r=n*2+1;
    while(l<r){
        int mi=l+(r-l)/2;
        vector<int>vc;
        vc={i};
        if((mi==n*2+1)||ask(n+1,mi,vc)!=(mi-(n+1)+1)){
            r=mi;
        }else{
            l=mi+1;
        }
    }
    e[i].push_back(l);
    l++;r=n*2+1;
    while(l<r){
        int mi=l+(r-l)/2;
        vector<int>vc;
        vc={i};
        if((mi==n*2+1)||ask(n+1,mi,vc)!=(mi-(n+1)+1)){
            r=mi;
        }else{
            l=mi+1;
        }
    }
    e[i].push_back(l);
    while(e[i].back()>=n*2+1){
        e[i].pop_back();
    }
}
return;
for(int i=1;i<=n;i++){
    for(auto v:e[i]){
        e[v].push_back(i);
    }
}

}
for(int i=1;i<=n*2;i++){
    if(e[i].size()==1){
        ans[i]=e[i][0];
        lvlv[i]=1;
    }
}
for(int i=1;i<=n*2;i++){
    if(e[i].size()==3){
        love[i]=slv(i,e[i]);
    }
}
for(int i=1;i<=n*2;i++){
    if(e[i].size()==1){continue;}
    if(e[i][0]!=love[i]&&(love[e[i][0]]!=i||lvlv[e[i][0]])){ans[i]=e[i][0];}
    if(e[i][1]!=love[i]&&(love[e[i][1]]!=i||lvlv[e[i][1]])){ans[i]=e[i][1];}
    if(e[i][2]!=love[i]&&(love[e[i][2]]!=i||lvlv[e[i][2]])){ans[i]=e[i][2];}
}

for(int i=1;i<=n*2;i++){
    if(ans[i]<i){
        Answer(i,ans[i]);
    }
}


}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 18 ms 596 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 33 ms 600 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 18 ms 596 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -