QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#789528#9810. Obliviate, Then ReincarnateCai_GuangWA 1ms3828kbC++201.2kb2024-11-27 20:42:112024-11-27 20:42:17

Judging History

This is the latest submission verdict.

  • [2024-11-27 20:42:17]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3828kb
  • [2024-11-27 20:42:11]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
const int inf=1e18;
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n,m,q;
    cin>>n>>m>>q;
    vector<int>vis(n,-inf),res(n,-1ll);
    vector<vector<array<int,2>>>e(n);
    auto get=[&](int x)->int{
        return ((x%n)+n)%n;
    };
    for(int i=0;i<m;++i){
        int x,y;
        cin>>x>>y;
        if(!y) continue;
        e[get(x)].push_back({x,y});
        if(y%n==0) res[get(x)]=1;
    }

    for(int i=0;i<n;++i){
        if(res[i]!=-1) continue;
        auto dfs=[&](auto dfs,int u)->int{
            int du=get(u);
            if(res[du]!=-1){
                return res[du];
            }
            if(vis[du]!=-inf){
                if(vis[du]==u) return -1;
                else return res[du]=1;
            }
            vis[du]=u;
            bool b=0;
            for(auto [x,y]:e[du]){
                b|=dfs(dfs,u+y);
            }
            vis[du]=-inf;
            return res[du]=b;
        };
        res[i]=dfs(dfs,i);
    }
    for(int i=0;i<q;++i){
        int x;
        cin>>x;
        cout<<(res[get(x)]?"Yes\n":"No\n");
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3604kb

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

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

input:

1 1 1
0 1000000000
-1000000000

output:

Yes

result:

ok "Yes"

Test #4:

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

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'