Submission #212375

# Submission time Handle Problem Language Result Execution time Memory
212375 2020-03-22T19:44:25 Z shahadbalghonaim Chameleon's Love (JOI20_chameleon) C++14
0 / 100
5 ms 512 KB
#include <bits/stdc++.h>
#include "chameleon.h"
//https://cms.ioi-jp.org/tasks/chameleon/descriptionusing namespace std;
using namespace std;
map<int,vector<int>>theval;
int binarysearch(vector<int>haha){
    int start=0,end=haha.size()-1;
    while(start!=end-1){
        int middle=(start+end)/2;
        vector<int>empty;
        for(int i=middle;i<(int)haha.size();i++){
            if(haha[i]!=-100000000)empty.push_back(haha[i]);
            
        }
        if(Query(empty)==(int)empty.size()){
           end=middle;
        }
        else{
            start=middle;
        }
    }
    return end;

}
void sh(int i,vector<int>&hehe){
    if(Query(hehe)!=(int)hehe.size()){
            int pos=binarysearch(hehe);
            theval[i].push_back(hehe[pos]);
            theval[hehe[pos]].push_back(i);
            int s=hehe[pos];
            hehe.erase(hehe.begin() + pos);
            if(Query(hehe)!=(int)hehe.size()){
               int pos=binarysearch(hehe);
               theval[i].push_back(hehe[pos]);
               theval[hehe[pos]].push_back(i); 
            }
            hehe.pop_back();
            hehe.push_back(pos);


            
        }


}
void Solve(int N){
    int n=N*2;
    vector<bool>solved(n+1,0);
    vector<int>one;
    vector<int>two;
    vector<int>three;
    vector<int>four;
    for(int i=1;i<=n;i++){
        bool nah=0;
        one.push_back(i);
        sh(i,one);
        if(one.size()>0&&one[one.size()-1]==i){nah=1;}
        two.push_back(i);
        sh(i,two);
        if(two.size()>0&&nah&&two[two.size()-1]==i){two.pop_back();}
        else if(two.size()>0&&two[two.size()-1]==i){nah=true;}
         three.push_back(i);
        sh(i,three);
        if(three.size()>0&&four.size()>0&&nah&&three[three.size()-1]==i){three.pop_back();}
        else if(three.size()>0&&three[three.size()-1]==i){nah=true;}
        four.push_back(i);
        sh(i,four);
        if(four.size()>0&&nah&&four[four.size()-1]==i){four.pop_back();}
        else if(four.size()>0&&four[four.size()-1]==i){nah=true;}
    }
    
    map<int,vector<int>>graph;
    for(int i=1;i<=n;i++){
     if(solved[i]==1)continue;
     if(theval[i].size()==1){Answer(i,theval[i][0]);solved[i]=1;solved[theval[i][0]]=1;continue;}
     if(Query({i,theval[i][0],theval[i][1]})==1){graph[i].push_back(theval[i][2]);graph[theval[i][2]].push_back(i);}
     else if(Query({i,theval[i][0],theval[i][2]})==1){graph[i].push_back(theval[i][1]);graph[theval[i][1]].push_back(i);}
     else if(Query({i,theval[i][2],theval[i][1]})==1){graph[i].push_back(theval[i][0]);graph[theval[i][0]].push_back(i);}

    }
    for(int i=1;i<=n;i++){
        if(solved[i]==1){continue;}
        int a=graph[i][0],b=graph[i][1];
        for(int j=0;j<3;j++){
            if(theval[i][j]!=a&&theval[i][j]!=b&&solved[theval[i][j]]==0){Answer(i,theval[i][j]);solved[i]=1;solved[theval[i][j]]=1;break;}
        }
    }

}

Compilation message

chameleon.cpp: In function 'void sh(int, std::vector<int>&)':
chameleon.cpp:31:17: warning: unused variable 's' [-Wunused-variable]
             int s=hehe[pos];
                 ^
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -