QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#798581#9810. Obliviate, Then Reincarnateucup-team4975RE 0ms0kbC++142.0kb2024-12-04 15:03:332024-12-04 15:03:33

Judging History

This is the latest submission verdict.

  • [2024-12-04 15:03:33]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 0kb
  • [2024-12-04 15:03:33]
  • Submitted

answer

#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define pbk push_back

#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif

#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif

#ifdef LOCAL
#define debugv(x)                   \
    cerr << setw(4) << #x << ":: "; \
    for (auto i : x)                \
        cerr << i << " ";           \
    cerr << endl
#else
#define debugv(x)
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
ostream& operator<<(ostream& out, PII& x)
{
    out << x.fir << " " << x.sec << endl;
    return out;
}

const ll MOD = 998244353;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int N = 200020;

ll negmod(ll x,ll mod){
	return ((x%mod)+mod)%mod;
}

void solve()
{
    ll n,m,q;
	cin>>n>>m>>q;
	vector<vector<ll>> G(n+1,vector<ll>());
	for(int i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		if(b!=0)G[negmod(a,n)].push_back(b);
	}
	stack<ll> st;
	vector<ll> belong(n),dfn(n),low(n),h(n);
	vector<bool> ans(n);
	ll cnt=0,T=0;
	function<void(ll)> tarjan=[&](ll d){
		ll u=negmod(d,n);
		dfn[u]=low[u]=++T;
		for(ll y:G[u]){
			ll v=negmod(d+y,n);
			if(!dfn[v]){
				h[v]=d+y;
				tarjan(v);
				low[u]=min(low[u],low[v]);
			}
			else if(!belong[v]){
				low[u]=min(low[u],dfn[v]);
				if(h[v]!=d+y)ans[v]=true;
			}
			ans[u]=ans[u]|ans[v];
		}
		if(dfn[u]==low[u]){
			belong[u]=++cnt;
			while(st.top()!=u){
				ll v=st.top();st.pop();
				belong[v]=cnt;
				ans[v]=ans[v]|ans[u];
			}
			st.pop();
		}
		return;
	};
	for(ll i=0;i<n;i++){
		if(!dfn[i]){
			h[i]=i;
			tarjan(i);
		}
	}
	while(q--){
		ll x;cin>>x;
		x=negmod(x,n);
		if(ans[x])cout<<"Yes\n";
		else cout<<"No\n";
	}
	return;
}
int main()
{
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    // cout.tie(nullptr);
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

3 2 3
1 1
-1 3
1
2
3

output:


result: