Submission #482881

# Submission time Handle Problem Language Result Execution time Memory
482881 2021-10-26T16:30:31 Z jalsol Connecting Supertrees (IOI20_supertrees) C++17
0 / 100
1 ms 204 KB
#ifdef LOCAL
#include "local.h"
#else
#include <bits/stdc++.h>
#define debug(...)
#define DB(...)
#endif

using namespace std;

const bool __initialization = []() {
    cin.tie(nullptr)->sync_with_stdio(false);
    cout << setprecision(12) << fixed;
    return true;
}();

using ll = long long;
using ld = long double;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

#define For(i, l, r) for (int i = (l); i <= (r); ++i)
#define Ford(i, r, l) for (int i = (r); i >= (l); --i)
#define Rep(i, n) For (i, 0, (n) - 1)
#define Repd(i, n) Ford (i, (n) - 1, 0)
#define Fe(...) for (auto __VA_ARGS__)

template <class C> inline int isz(const C& c) { return static_cast<int>(c.size()); }
template <class T> inline bool chmin(T& a, const T& b) { return (a > b) ? a = b, true : false; }
template <class T> inline bool chmax(T& a, const T& b) { return (a < b) ? a = b, true : false; }

constexpr ld eps = 1e-9;
constexpr int inf = 1e9;
constexpr ll linf = 1e18;

// =============================================================================

#include "supertrees.h"

constexpr int maxn = 3e5 + 5;

int construct(vector<vector<int>> req) {
    int n = req.size();
    vector<vector<int>> ans(n, vector<int>(n));
    vector<vector<int>> g(n);

    Rep (i, n) {
        Rep (j, n) {
            if (!req[i][j]) continue;
            g[i].push_back(j);
            g[j].push_back(i);
        }
    }

    vector<int> comp;
    vector<bool> vis(n);

    auto Dfs = [&](auto self, int u) -> void {
        vis[u] = true;
        comp.push_back(u);

        Fe (v : g[u]) {
            if (!vis[v]) {
                self(self, v);
            }
        }
    };

    Rep (i, n) {
        if (vis[i]) continue;

        Dfs(Dfs, i);

        int sz = isz(comp);
        if (sz == 2) return 0;

        Rep (j, sz - 1) {
            ans[comp[j]][comp[j + 1]] = ans[comp[j + 1]][comp[j]] = 1;
        }
        ans[comp[0]][comp[sz - 1]] = ans[comp[sz - 1]][comp[0]] = 1;

        Rep (j, sz) {
            Rep (k, sz) {
                if (!req[comp[j]][comp[k]]) {
                    return 0;
                }
            }
        }

        comp.clear();
    }

    build(ans);
    return 1;
}

// does oj.uz allow IOI-style scoring?
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -