Submission #1072541

#TimeUsernameProblemLanguageResultExecution timeMemory
1072541ewirlanWerewolf (IOI18_werewolf)C++17
15 / 100
4042 ms44372 KiB
//
#ifndef __SIZEOF_INT128__
  #define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
//#define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
    string name{""};
    time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
    duration<float, std::milli> dur;
    Timer() = default;
    Timer(string nm): name(nm) {}
    ~Timer() {
        end = high_resolution_clock::now(); dur= end - start;
        cout << "@" << name << "> " << dur.count() << " ms" << '\n';
    }
};
template <typename T = int> inline T in()
{
    static T x;
    std::cin >> x;
    return x;
}
std::string yn(bool b)
{
    if(b) return "YES\n";
    else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
    for(const auto& i : wek)out << i << ' ';
    return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
    out << '{'<<par.first<<", "<<par.second<<"}";
    return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
constexpr int maxn = 2e5 + 3;
vector <int> graf[maxn];
vector <int> gra[maxn][2];
int byl[maxn][2];
void dfs(int w, bool b){
    if(byl[w][b])return;
    byl[w][b] = 1;
    for(auto i: gra[w][b])dfs(i, b);
}
vector <int> check_validity (int n, vector <int> x, vector <int> y, vector <int> a, vector <int> b, vector <int> l, vector <int> r)
{
    int m(sz(x)), q(sz(a));
    rep(i, 0, m){
        graf[x[i]].pb(y[i]);
        graf[y[i]].pb(x[i]);
    }
    vector <int> odp;
    rep(i, 0, q){
        rep(i, 0, n){
            gra[i][0].clear();
            gra[i][1].clear();
            byl[i][0] = byl[i][1] = 0;
        }
        rep(w, l[i], n)for(auto j: graf[w])if(j >= l[i]){
            gra[w][0].pb(j);
            gra[j][0].pb(w);
        }
        rep(w, 0, r[i]+1)for(auto j: graf[w])if(j <= r[i]){
            gra[w][1].pb(j);
            gra[j][1].pb(w);
        }
        dfs(a[i], 0);
        dfs(b[i], 1);
        bool o(0);
        rep(i, 0, n)o |= byl[i][0] && byl[i][1];
        odp.pb(o);
    }
    return odp;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...