QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#789852#9810. Obliviate, Then ReincarnateCai_GuangWA 0ms3564kbC++201.4kb2024-11-27 22:16:312024-11-27 22:16:31

Judging History

This is the latest submission verdict.

  • [2024-11-27 22:16:31]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3564kb
  • [2024-11-27 22:16:31]
  • 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;
        stack<int>st;
        auto dfs=[&](auto dfs,int u)->int{
            int du=get(u);
            st.push(du);
            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;
            int b=-1;
            for(auto [x,y]:e[du]){
                if(dfs(dfs,u+y)==1) b=1;
            }
            vis[du]=-inf;
            return res[du]=b;
        };
        while(!st.empty()){
            auto u=st.top();
            st.pop();
            if(res[u]==-1) res[u]=0;
        }
        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: 0
Wrong Answer
time: 0ms
memory: 3564kb

input:

3 2 3
1 1
-1 3
1
2
3

output:

Yes
Yes
Yes

result:

wrong answer 3rd words differ - expected: 'No', found: 'Yes'