QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#808412#9810. Obliviate, Then ReincarnateMiniLong#WA 2ms9932kbC++203.6kb2024-12-10 20:39:552024-12-10 20:39:56

Judging History

This is the latest submission verdict.

  • [2024-12-10 20:39:56]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 9932kb
  • [2024-12-10 20:39:55]
  • Submitted

answer

#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<int, int> PII;
namespace fastio{
    #ifdef ONLINE_JUDGE
    char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
    #define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
    #else
    #define get() getchar()
    #endif
    template<typename T> inline void read(T &t){
        T x = 0, f = 1;
        char c = getchar();
        while(!isdigit(c)){
            if(c == '-') f = -f;
            c = getchar();
        }
        while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
        t = x * f;
    }
    template<typename T, typename ... Args> inline void read(T &t, Args&... args){
        read(t);
        read(args...);
    }
    template<typename T> void write(T t){
        if(t < 0) putchar('-'), t = -t;
        if(t >= 10) write(t / 10);
        putchar(t % 10 + '0');
    }
    template<typename T, typename ... Args> void write(T t, Args... args){
        write(t), putchar(' '), write(args...);
    }
    template<typename T> void writeln(T t){
        write(t);
        puts("");
    }
    template<typename T> void writes(T t){
        write(t), putchar(' ');
    }
    #undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
    const ll mod = 998244353;
    ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
    void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
    void add(ll &x, ll y){x = (x + y) % mod;}
    void mul(ll &x, ll y){x = x * y % mod;}
    ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
    ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
    ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
const int N = 5e5 + 5;
int n, m, q, in[N];
bool vis[N], f[N], g[N];
vector<int> G[N], e[N];
int id, num, dfn[N], low[N], bel[N];
int top, st[N];
void tarjan(int u){
    dfn[u] = low[u] = ++id, st[++top] = u, vis[u] = 1;
    for(auto &v : G[u]){
        if(!dfn[v]) tarjan(v), low[u] = min(low[u], low[v]);
        else if(!vis[v]) low[u] = min(low[u], dfn[v]);
    }
    if(low[u] == dfn[u]){
        num++;
        int cnt = 0;
        for(int x = 0; x != u; top--){
            x = st[top], bel[x] = num, vis[x] = 0;
            cnt++;
        }
        if(cnt > 1 || g[u]) f[num] = 1;
    }
}
void init(){
    _rep(i, 0, n - 1) if(!dfn[i]) tarjan(i);
    _rep(i, 0, n - 1) for(auto &j : G[i]) if(bel[i] != bel[j]) e[bel[j]].pb(bel[i]), in[bel[i]]++;
    queue<int> q;
    _rep(i, 1, num) if(!in[i]) q.push(i);
    while(q.size()){
        int u = q.front(); q.pop();
        for(auto &v : e[u]){
            f[v] |= f[u];
            if(!--in[v]) q.push(v);
        }
    }
}
int main(){
    read(n, m, q);
    _rep(i, 1, m){
        int x, y; read(x, y);
        if(!y) continue;
        x = (x % n + n) % n, y %= n;
        debug("(%d,%d)\n", x, y);
        if(!y) g[x] = 1;
        else G[x].pb((x + y) % n);
    }
    init();
    while(q--){
        int x; read(x);
        x = (x % n + n) % n;
        puts(f[bel[x]] ? "Yes" : "No");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 9800kb

input:

3 2 3
1 1
-1 3
1
2
3

output:

Yes
Yes
No

result:

ok 3 tokens

Test #2:

score: 0
Accepted
time: 2ms
memory: 9756kb

input:

3 2 3
1 1
-1 0
1
2
3

output:

No
No
No

result:

ok 3 tokens

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 9932kb

input:

1 1 1
0 1000000000
-1000000000

output:

No

result:

wrong answer 1st words differ - expected: 'Yes', found: 'No'