Submission #1054733

#TimeUsernameProblemLanguageResultExecution timeMemory
1054733c2zi6Connecting Supertrees (IOI20_supertrees)C++14
21 / 100
144 ms28084 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "supertrees.h"

int n;
VVI p;

VVI comps() {
    VVI s = p;
    sort(all(s));
    VVI ret;
    for (int i = 0; i < n; i++) {
        if (i == 0 || s[i] != s[i-1]) {
            if (i) rep(j, n) {
                if (s[i][j] && s[i-1][j]) {
                    return VVI();
                }
            }
            ret.pb(VI());
            rep(j, n) if (s[i][j]) ret.back().pb(j);
        }
    }
    return ret;
}

int construct(VVI P_ARG) {
    p = P_ARG;
    n = p.size();

    VVI comp = comps();
    if (comp.size() == 0) return 0;

    VVI ans(n, VI(n));
    for (VI vec : comp) {
        replr(i, 1, vec.size()-1) {
            ans[vec[0]][vec[i]] = true;
            ans[vec[i]][vec[0]] = true;
        }
    }
    build(ans);
	return 1;
}





#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...