Submission #935268

# Submission time Handle Problem Language Result Execution time Memory
935268 2024-02-29T02:10:35 Z 1075508020060209tc Chameleon's Love (JOI20_chameleon) C++14
60 / 100
25 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);
    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-(ls+1)+1)){
            r=mi;
        }else{
            l=mi+1;
        }
    }
    e[i].push_back(l);
    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-(ls+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]);
    }
}


}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 18 ms 512 KB Wrong Answer [5]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 344 KB Output is correct
6 Correct 1 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 0 ms 344 KB Output is correct
# Verdict Execution time Memory 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 1 ms 344 KB Output is correct
6 Correct 1 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 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 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 588 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 23 ms 520 KB Output is correct
4 Correct 25 ms 344 KB Output is correct
5 Correct 23 ms 344 KB Output is correct
6 Correct 23 ms 516 KB Output is correct
7 Correct 23 ms 524 KB Output is correct
8 Correct 23 ms 344 KB Output is correct
9 Correct 25 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Incorrect 18 ms 512 KB Wrong Answer [5]
4 Halted 0 ms 0 KB -