Submission #734881

# Submission time Handle Problem Language Result Execution time Memory
734881 2023-05-03T08:09:35 Z Elvin_Fritl Comparing Plants (IOI20_plants) C++17
Compilation error
0 ms 0 KB
//#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;

void build(vector<vector<int> > b);

bool vis[1002];
int construct(vector<vector<int> > p) {
    int n = (int)p.size();
    vector<vector<int> > ans(n);
    for(int i=0;i<n;i++) ans[i].resize(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(p[i][j] == 3) return 0;
        }
    }
    for(int i=0;i<n;i++){
        if(vis[i]) continue;
        vis[i] = 1;

        vector<int> x;
        vector<vector<int> > y;
        queue<int> q;
        q.push(i);
        while(!q.empty()){
            int u = q.front();
            q.pop();
            vis[u] = 1;
            bool use = 0;
            x.push_back(u);
            vector<int> z;
            for(int v=0;v<n;v++){
                if(vis[v]) continue;
                if(p[u][v] == 0) continue;
                if(p[u][v] == 1){
                    ans[u][v] = 1;
                    ans[v][u] = 1;
                    vis[v] = 1;
                    z.push_back(v);
                }
                else if(!use){
                    use = 1;
                    q.push(v);
                }
            }
            y.push_back(z);
        }
        for(int i=0;i<(int)y.size();i++){
            for(int j=0;j<(int)y[i].size();j++){
                for(int k=j+1;k<(int)y[i].size();k++){
                    if(p[y[i][j]][y[i][k]] != 1) return 0;
                }
            }
            for(int j=0;j<(int)x.size();j++){
                if(i == j) continue;
                for(int k=0;k<(int)y[i].size();k++){
                    if(p[x[j]][y[i][k]] != 2) return 0;
                }
            }
            for(int j=0;j<(int)y.size();j++){
                if(i == j) continue;
                for(int a=0;a<(int)y[i].size();a++){
                    for(int b=0;b<(int)y[j].size();b++){
                        if(p[y[i][a]][y[j][b]] != 2) return 0;
                    }
                }
            }
        }
        for(int i=0;i<(int)x.size();i++){
            for(int j=i+1;j<(int)x.size();j++){
                if(p[x[i]][x[j]] != 2) return 0;
            }
        }
        if((int)x.size() == 2) return 0;
        else if((int)x.size() > 2){
            for(int i=0;i<(int)x.size()-1;i++){
                ans[x[i]][x[i+1]] = 1;
                ans[x[i+1]][x[i]] = 1;
            }
            ans[0][x[(int)x.size()-1]] = 1;
            ans[x[(int)x.size()-1]][0] = 1;
        }
    }

    build(ans);
    return 1;
}

Compilation message

/usr/bin/ld: /tmp/cc7chxeg.o: in function `construct(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)':
plants.cpp:(.text+0x763): undefined reference to `build(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >)'
/usr/bin/ld: /tmp/cc5MC83d.o: in function `main':
grader.cpp:(.text.startup+0x2f6): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x32f): undefined reference to `compare_plants(int, int)'
collect2: error: ld returned 1 exit status