QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#809245#9810. Obliviate, Then ReincarnateOIer_kzc#WA 2ms7792kbC++201.1kb2024-12-11 13:28:372024-12-11 13:28:37

Judging History

This is the latest submission verdict.

  • [2024-12-11 13:28:37]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 7792kb
  • [2024-12-11 13:28:37]
  • Submitted

answer

#include <stdio.h>
#include <string.h>

#include <queue>
#include <algorithm>

#define LOG(FMT...) fprintf(stderr, FMT)

#define fi first
#define se second
#define em emplace
#define eb emplace_back

using namespace std;

typedef long long LL;
constexpr int N = 500005;

int n, m, Q;
bool was[N], f[N];
LL ver[N];
vector<int> e[N];

int sid(LL x) {
	x %= n;
	if (x < 0) x += n;
	return (int)x;
}

bool dfs(LL s) {
	int x = sid(s);
	if (was[x]) {
		return f[x];
	}
	was[x] = true;
	f[x] = false;
	ver[x] = s;
	for (int d : e[x]) {
		LL t = s + d;
		int y = sid(t);
		if (ver[y] == t) {
			continue;
		}
		if (~ver[y]) {
			f[x] = true;
			break;
		}
		dfs(t);
		f[x] |= f[y];
	}
	ver[x] = -1;
	return f[x];
}

int main() {
	scanf("%d%d%d", &n, &m, &Q);
	for (int x = 0; x < n; ++x) {
		e[x].clear();
	}
	for (int i = 0, a, b; i < m; ++i) {
		scanf("%d%d", &a, &b);
		e[sid(a)].eb(b);
	}
	memset(was, 0, n);
	memset(ver, -1, n << 2);
	while (Q--) {
		int x;
		scanf("%d", &x);
		x = sid(x);
		puts(dfs(x) ? "Yes" : "No");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 7792kb

input:

3 2 3
1 1
-1 3
1
2
3

output:

Yes
Yes
No

result:

ok 3 tokens

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5880kb

input:

3 2 3
1 1
-1 0
1
2
3

output:

Yes
No
No

result:

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