Submission #599685

#TimeUsernameProblemLanguageResultExecution timeMemory
599685skittles1412늑대인간 (IOI18_werewolf)C++17
15 / 100
4077 ms32172 KiB
#include "bits/extc++.h"

using namespace std;

template <typename T>
void dbgh(const T& t) {
    cerr << t << endl;
}

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
    cerr << t << " | ";
    dbgh(u...);
}

#ifdef DEBUG
#define dbg(...)                                              \
    cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
    dbgh(__VA_ARGS__);
#else
#define dbg(...)
#define cerr   \
    if (false) \
    cerr
#endif

using vi = vector<int>;

#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())

vi check_validity(int n, vi us, vi vs, vi qsrc, vi qdest, vi ql, vi qr) {
    int m = sz(us), q = sz(qsrc);
    if (n <= 3000 && m <= 6000 && q <= 3000) {
        vector<int> graph[n];
        for (int i = 0; i < m; i++) {
            graph[us[i]].push_back(vs[i]);
            graph[vs[i]].push_back(us[i]);
        }
        vector<int> ans(q);
        for (int qi = 0; qi < q; qi++) {
            int src = qsrc[qi], dest = qdest[qi], l = ql[qi], r = qr[qi];
            bool vis[n][2] {};
            vector<pair<int, int>> q;
            auto push = [&](int u, int t) -> void {
                if (!vis[u][t]) {
                    vis[u][t] = true;
                    q.emplace_back(u, t);
                }
            };
            push(src, 0);
            while (sz(q)) {
                auto [u, t] = q.back();
                q.pop_back();
                if (l <= u && u <= r && !t) {
                    push(u, 1);
                }
                for (auto& v : graph[u]) {
                    if ((!t && v >= l) || (t && v <= r)) {
                        push(v, t);
                    }
                }
            }
            ans[qi] = vis[dest][1];
        }
        return ans;
    }
}

Compilation message (stderr)

werewolf.cpp: In function 'vi check_validity(int, vi, vi, vi, vi, vi, vi)':
werewolf.cpp:69:1: warning: control reaches end of non-void function [-Wreturn-type]
   69 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...