Submission #304318

#TimeUsernameProblemLanguageResultExecution timeMemory
304318Jarif_Rahman슈퍼트리 잇기 (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include "mysupertrees.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
vector<vector<int>> v;
vector <vector<int>> dsu1, dsu11;
vector <int> dsu2, dsu12;
void unite(int a, int b){
    if(dsu2[a] == dsu2[b]) return;
    int x = dsu2[a], y = dsu2[b];
    if(dsu1[x].size() < dsu1.size()){
        while(!dsu1[x].empty()){
            int ss = dsu1[x].back();
            dsu1[x].pop_back();
            dsu2[ss] = y;
            dsu1[y].pb(ss);
        }
    }
    else{
        while(!dsu1[y].empty()){
            int ss = dsu1[y].back();
            dsu1[y].pop_back();
            dsu2[ss] = x;
            dsu1[x].pb(ss);
        }
    }
}
void unite1(int a, int b){
    if(dsu12[a] == dsu12[b]) return;
    int x = dsu12[a], y = dsu12[b];
    if(dsu11[x].size() < dsu11.size()){
        while(!dsu11[x].empty()){
            int ss = dsu11[x].back();
            dsu11[x].pop_back();
            dsu12[ss] = y;
            dsu11[y].pb(ss);
        }
    }
    else{
        while(!dsu1[y].empty()){
            int ss = dsu1[y].back();
            dsu1[y].pop_back();
            dsu2[ss] = x;
            dsu1[x].pb(ss);
        }
    }
}
int construct(vector<vector<int>> p){
    v.clear();
    dsu1.clear();
    dsu2.clear();
    dsu11.clear();
    dsu12.clear();
    int n = p.size();
    v = vector<vector<int>>(n, vector<int>(n, 0));
    dsu1 = vector<vector<int>>(n);
    dsu2 = vector<int>(n);
    for(int i = 0; i < n ; i++) dsu1[i].pb(i);
    for(int i = 0; i < n; i++) dsu2[i] = i;
    dsu11 = dsu1;
    dsu12 =  dsu2;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(p[i][j] != 0) unite(i, j);
    bool bl = 1;
    for(auto sth: dsu1){
        if(sth.size() < 2) continue;
        for(int i = 0; i < sth.size(); i++) for(int j = 0; j < sth.size(); j++){
            if(i == j) continue;
            if(p[sth[i]][sth[j]] == 0){
                bl = 0;
                break;
            }
        }
    }
    if(!bl) return 0;
    for(auto sth: dsu1){
        if(sth.size() < 2) continue;
        vector <int> two, one;
        for(int x: sth) for(int y: sth){
            if(x == y) continue;
            if(p[x][y] == 1) unite1(x, y);
        }
        for(int x: sth){
            int o = 0,tw = 0;
            for(int k = 0; k < n; k++){
              	if(k == x) continue;
                if(p[x][k] == 1) o++;
            }
            if(o == 0) two.pb(x);
            else one.pb(x);
        }
        for(int a: sth){
            if(dsu11[a].size() < 2) continue;
            for(int i = 0; i < dsu11[a].size() - 1; i++){
                int x = dsu11[a][i], y = dsu11[a][i+1];
                v[x][y] = 1;
                v[y][x] = 1;
            }
        }
        vector <int> oo;
        for(int a: sth) if(dsu11[a].size() > 0) oo.pb(dsu11[a][0]);
        for(int i = 1; i < oo.size(); i++){
            int x = oo[i], y = oo[i-1];
            v[x][y] = 1;
            v[y][x] = 1;
        }
        if(oo.size() > 1){
            int x = oo[0], y = oo.back();
            v[x][y] = 1;
            v[y][x] = 1;
        }
    }
    build(v);
    return 1;
}
int main(){
//    construct({
//              {1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0},
//              {2, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0},
//              {2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0},
//              {2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0},
//              {0, 0, 0, 0, 1, 2, 2, 2, 0, 0, 0},
//              {0, 0, 0, 0, 2, 1, 2, 2, 0, 0, 0},
//              {0, 0, 0, 0, 2, 2, 1, 2, 0, 0, 0},
//              {0, 0, 0, 0, 2, 2, 2, 1, 0, 0, 0},
//              {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
//              {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
//              {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
//              });
    //construct({  {1, 1, 1}, {1, 1, 1}, {1, 1, 1}  });
}

Compilation message (stderr)

supertrees.cpp:1:10: fatal error: mysupertrees.h: No such file or directory
    1 | #include "mysupertrees.h"
      |          ^~~~~~~~~~~~~~~~
compilation terminated.