QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#780686#9810. Obliviate, Then Reincarnatehhhyh#WA 0ms3632kbC++231.0kb2024-11-25 12:24:402024-11-25 12:24:41

Judging History

This is the latest submission verdict.

  • [2024-11-26 23:19:26]
  • hack成功,自动添加数据
  • (/hack/1260)
  • [2024-11-25 12:24:41]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3632kb
  • [2024-11-25 12:24:40]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define all(x) x.begin(), x.end()
void solve()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> f(n), cyc(n);
    iota(all(f), 0ll);
    auto find = [&](auto find, int x) -> int
    {
        return f[x] == x ? f[x] : f[x] = find(find, f[x]);
    };
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a = (a % n + n) % n;
        if(b==0)continue;
        b = (b % n + n) % n;
        b = (b + a) % n;
        a = find(find, a), b = find(find, b);
        if (a == b)
            cyc[a] = 1;
        f[a] = b;
    }
    for (int i = 0; i < q; i++)
    {
        int x;
        cin >> x;
        x = (x % n + n) % n;
        if (cyc[find(find, x)])
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    while (T--)
        solve();
}
/*
 3 2 3
 1 1
 -1 0
 1
 2
 3
*/

詳細信息

Test #1:

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

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: 0ms
memory: 3620kb

input:

3 2 3
1 1
-1 0
1
2
3

output:

No
No
No

result:

ok 3 tokens

Test #3:

score: 0
Accepted
time: 0ms
memory: 3500kb

input:

1 1 1
0 1000000000
-1000000000

output:

Yes

result:

ok "Yes"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3632kb

input:

3 2 3
0 1000000000
1 -1000000000
-1000000000
0
-1000000000

output:

No
Yes
No

result:

wrong answer 2nd words differ - expected: 'No', found: 'Yes'