Submission #1012462

#TimeUsernameProblemLanguageResultExecution timeMemory
1012462c2zi6늑대인간 (IOI18_werewolf)C++14
15 / 100
4067 ms38636 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 "werewolf.h"

int n;
VVI gp;

void dfs(int u, VI& vis, int mn, int mx) {
    vis[u] = true;
    for (int v : gp[u]) if (!vis[v]) {
        if (mn <= v && v <= mx) {
            dfs(v, vis, mn, mx);
        }
    }
}

VI check_validity(int N, VI X, VI Y, VI S, VI E, VI L, VI R) {
    n = N;
    gp = VVI(n);
    rep(i, X.size()) {
        gp[X[i]].pb(Y[i]);
        gp[Y[i]].pb(X[i]);
    }

    VI ansret;
    rep(i, S.size()) {
        auto[s, e, l, r] = make_tuple(S[i], E[i], L[i], R[i]);
        VI visa, visb;
        visa = visb = VI(n);
        dfs(s, visa, l, +2e9);
        dfs(e, visb, -2e9, r);
        /*cout << "visa: ";*/
        /*for (int x : visa) cout << x << " ";*/
        /*cout << endl;*/
        /*cout << "visb: ";*/
        /*for (int x : visb) cout << x << " ";*/
        /*cout << endl;*/
        bool ans = false;
        rep(u, n) if (visa[u] && visb[u]) ans = true;
        ansret.pb(ans);
    }
    return ansret;
}





Compilation message (stderr)

werewolf.cpp: In function 'VI check_validity(int, VI, VI, VI, VI, VI, VI)':
werewolf.cpp:56:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   56 |         auto[s, e, l, r] = make_tuple(S[i], E[i], L[i], R[i]);
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...