Submission #101233

# Submission time Handle Problem Language Result Execution time Memory
101233 2019-03-18T02:47:13 Z ShaneOng ICC (CEOI16_icc) C++14
Compilation error
0 ms 0 KB
#include "icc.h"
using namespace std;

typedef pair<int,int> ii;
vector<int> col,adj[109];
void dfs(int u){
    for(int v:adj[u]){
        if(col[v]==-1){
            col[v]=1-col[u];
            dfs(v);
        }
    }
}
ii stuff(vector<int> a,vector<int> b){
    int qu=query(a.size(),b.size(),&a[0],&b[0]);
    /*printf("\na:");
    for(int x:a)
        printf("%d ",x);
    printf("\n");
    printf("b:");
    for(int x:b)
        printf("%d ",x);
    printf("\n");*/
    int na=(int)a.size(),nb=(int)b.size();
    ii res=ii(-1,-1);
    if(qu==0){
        vector<int> aa,ab,ba,bb;
        if(na>1){
            for(int x=0;x<na;x++){
                if(x<na/2)
                    aa.push_back(a[x]);
                else
                    ab.push_back(a[x]);
            }
            res=max(res,stuff(aa,ab));
        }
        if(nb>1){
            for(int x=0;x<nb;x++){
                if(x<nb/2)
                    ba.push_back(b[x]);
                else
                    bb.push_back(b[x]);
            }
            res=max(res,stuff(ba,bb));
        }

        return res;
    }else{
        while((int)a.size()>1){
            vector<int> a1,a2;
            for(int x=0;x<(int)a.size();x++){
                if(x<(int)a.size()/2)
                    a1.push_back(a[x]);
                else
                    a2.push_back(a[x]);
            }
            int qu=query(a1.size(),b.size(),&a1[0],&b[0]);
            if(qu==0){
                a=a2;
            }else
                a=a1;
        }
        while((int)b.size()>1){
            vector<int> b1,b2;
            for(int x=0;x<(int)b.size();x++){
                if(x<(int)b.size()/2)
                    b1.push_back(b[x]);
                else
                    b2.push_back(b[x]);
            }
            int qu=query(a.size(),b1.size(),&a[0],&b1[0]);
            if(qu==0){
                b=b2;
            }else
                b=b1;
        }
        //printf("%d %d\n",a[0],b[0]);
        return ii(a[0],b[0]);

    }
}
void run(int n) {
    for(int x=0;x<n-1;x++){
        col.assign(n,-1);
        vector<int> arr[4];
        for(int y=0;y<n;y++){
            if(col[y]==-1){
                col[y]=y%2;
                arr[y%2].push_back(y+1);
                dfs(y);
            }else{
                arr[col[y]+2].push_back(y+1);
            }
        }
        ii ans=max(stuff(arr[0],arr[2]),stuff(arr[1],arr[3]));
        adj[ans.first-1].push_back(ans.second-1);
        adj[ans.second-1].push_back(ans.first-1);
        //printf("%d %d\n",ans.first,ans.second);
        setRoad(ans.first,ans.second);
    }
}

Compilation message

icc.cpp:4:9: error: 'pair' does not name a type
 typedef pair<int,int> ii;
         ^~~~
icc.cpp:5:1: error: 'vector' does not name a type
 vector<int> col,adj[109];
 ^~~~~~
icc.cpp: In function 'void dfs(int)':
icc.cpp:7:15: error: 'adj' was not declared in this scope
     for(int v:adj[u]){
               ^~~
icc.cpp:8:12: error: 'col' was not declared in this scope
         if(col[v]==-1){
            ^~~
icc.cpp:8:12: note: suggested alternative: 'bool'
         if(col[v]==-1){
            ^~~
            bool
icc.cpp: At global scope:
icc.cpp:14:1: error: 'ii' does not name a type
 ii stuff(vector<int> a,vector<int> b){
 ^~
icc.cpp: In function 'void run(int)':
icc.cpp:84:9: error: 'col' was not declared in this scope
         col.assign(n,-1);
         ^~~
icc.cpp:84:9: note: suggested alternative: 'bool'
         col.assign(n,-1);
         ^~~
         bool
icc.cpp:85:9: error: 'vector' was not declared in this scope
         vector<int> arr[4];
         ^~~~~~
icc.cpp:85:16: error: expected primary-expression before 'int'
         vector<int> arr[4];
                ^~~
icc.cpp:89:17: error: 'arr' was not declared in this scope
                 arr[y%2].push_back(y+1);
                 ^~~
icc.cpp:92:17: error: 'arr' was not declared in this scope
                 arr[col[y]+2].push_back(y+1);
                 ^~~
icc.cpp:95:9: error: 'ii' was not declared in this scope
         ii ans=max(stuff(arr[0],arr[2]),stuff(arr[1],arr[3]));
         ^~
icc.cpp:96:9: error: 'adj' was not declared in this scope
         adj[ans.first-1].push_back(ans.second-1);
         ^~~
icc.cpp:96:13: error: 'ans' was not declared in this scope
         adj[ans.first-1].push_back(ans.second-1);
             ^~~