Submission #313559

#TimeUsernameProblemLanguageResultExecution timeMemory
313559mohamedsobhi777슈퍼트리 잇기 (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
#include "supertrees.h"
#include <bits/stdc++.h>
#include <vector>

using namespace std;

std::vector<std::vector<int>> answer;
int vis[100000];
bool bad;
int nn;

vector<int> vecs(int x)
{
        vector<int> ret;
        queue<int> qu;
        qu.push(x);
        while (qu.size())
        {
                int x = qu.front();
                qu.pop();
                if (vis[x]++)
                        continue;
                ret.push_back(x);
                for (int i = 0; i < n; ++i)
                {
                        if (i == x || vis[i] || !p[x][i])
                                continue;
                        qu.push(i);
                }
        }
        return ret;
}

void solve(vector<int> vecs)
{
        if (!vecs.size())
                return;
        int sz = (int)vecs.size();
        vector<int> cycle, line;
        for (int i = 0; i < sz; ++i)
        {
                for (int j = 0; j < sz; ++j)
                {
                        if (i == j)
                                continue;
                        if (p[vecs[i]][vecs[j]] != 2)
                        {
                                line.push_back(i);
                                break;
                        }
                }
                if (line.empty() || line.back() != i)
                        cycle.push_back(i);
        }
        if (cycle.size() == 1)
                bad = 1;
        if (line.size() && cycle.size())
                cycle.push_back(line[0]);
        for (int i = 0; i < (int)cycle.size(); ++i)
        {
        }
        for (int i = 1; i < (int)line.size(); ++i)
        {
                int x = vecs[line[i]], y = vecs[line[i - 1]];
                answer[x][y] = answer[y][x] = 1;
        }
        for (int i = 0; i < line.size(); ++i)
        {
                for (int j = 0; j < line.size(); ++j)
                {
                        if (i == j)
                                continue;
                        if (p[vecs[i]][vecs[j]] != 1)
                                bad = 1;
                }
        }
}

int construct(std::vector<std::vector<int>> p)
{
        nn = p.size();
        for (int i = 0; i < nn; i++)
        {
                std::vector<int> row;
                row.resize(n);
                answer.push_back(row);
        }
        for (int i = 0; i < nn; ++i)
        {
                vector<int> g = vecs(i);
                solve(g);
        }
        if (bad)
                return 0;
        build(answer);
        return 1;
}

Compilation message (stderr)

supertrees.cpp: In function 'std::vector<int> vecs(int)':
supertrees.cpp:24:37: error: 'n' was not declared in this scope
   24 |                 for (int i = 0; i < n; ++i)
      |                                     ^
supertrees.cpp:26:50: error: 'p' was not declared in this scope
   26 |                         if (i == x || vis[i] || !p[x][i])
      |                                                  ^
supertrees.cpp: In function 'void solve(std::vector<int>)':
supertrees.cpp:46:29: error: 'p' was not declared in this scope
   46 |                         if (p[vecs[i]][vecs[j]] != 2)
      |                             ^
supertrees.cpp:67:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |         for (int i = 0; i < line.size(); ++i)
      |                         ~~^~~~~~~~~~~~~
supertrees.cpp:69:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |                 for (int j = 0; j < line.size(); ++j)
      |                                 ~~^~~~~~~~~~~~~
supertrees.cpp:73:29: error: 'p' was not declared in this scope
   73 |                         if (p[vecs[i]][vecs[j]] != 1)
      |                             ^
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:85:28: error: 'n' was not declared in this scope
   85 |                 row.resize(n);
      |                            ^