QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#781215#9810. Obliviate, Then ReincarnateA_J1e#WA 2ms7948kbC++231.6kb2024-11-25 15:16:402024-11-25 15:16:40

Judging History

This is the latest submission verdict.

  • [2024-11-26 23:19:26]
  • hack成功,自动添加数据
  • (/hack/1260)
  • [2024-11-25 15:16:40]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 7948kb
  • [2024-11-25 15:16:40]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using i32 = int;
using i64 = long long;
using i128=__int128;
const int N = 5e5 + 10;
#define endl "\n"
bool ok[N];
int n, m , q;
vector<int > e[N];
vector<int > e2[N];
int du[N];
int du2[N];
void topu()
{
    queue<int > q;
    vector<bool > st(n + 10);
    for(int i = 0 ; i < n ; i++)
        if(du[i] == 0) q.push(i) , st[i] = 1;
    while(!q.empty())
    {
        int tmp = q.front();
        q.pop();
        for(int v : e[tmp])
        {
            du[v]--;
            if(du[v] == 0)
                st[v] = 1 ,q.push(v);
        }
    }
    for(int i = 0 ; i < n ; i++)
        if((!st[i]) && du2[i]) ok[i] = 1;
    for(int i = 0 ; i < n ; i++)
        if(ok[i])
            q.push(i);
    while(!q.empty())
    {
        int tmp = q.front();
        q.pop();
        for(int v : e2[tmp])
            if(!ok[v])
                ok[v] = 1, q.push(v);
    }
}
void solve()
{
    cin >> n >> m >> q;
    for(int i = 1 ; i <= m ; i++)
    {
        int a, b;
        cin >> a >> b;
        a = ((a % n) + n) % n;
        if(b != 0) du2[a]++;
        b = (a + b) % n;
        e[a].push_back(b);
        du[b]++;
        e2[b].push_back(a);
    }
    topu();
    while(q--)
    {
        int tmp;
        cin >> tmp;
        tmp = ((tmp % n) + n) % n;
        if(ok[tmp])
            cout << "Yes" << endl;
        else 
            cout << "No" << endl;
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    i32 t=1;
    while(t--) solve();
}

详细

Test #1:

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

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: 5616kb

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: 1ms
memory: 3636kb

input:

1 1 1
0 1000000000
-1000000000

output:

Yes

result:

ok "Yes"

Test #4:

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

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'