답안 #935265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935265 2024-02-29T02:08:37 Z 1075508020060209tc 카멜레온의 사랑 (JOI20_chameleon) C++14
컴파일 오류
0 ms 0 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);
    int ls=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(l+1,mi,vc)<=(mi-(n+1)+1)){
            r=mi;
        }else{
            l=mi+1;
        }
    }
    e[i].push_back(l);
    int ls=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(ls+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();
    }
}

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].size()==3){
    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]){
        ans[ans[i]]=i;
    }
}

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


}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:85:9: error: redeclaration of 'int ls'
   85 |     int ls=l;
      |         ^~
chameleon.cpp:72:9: note: 'int ls' previously declared here
   72 |     int ls=l;
      |         ^~