为什么G题暴力能过?
  • 板块灌水区
  • 楼主aulive
  • 当前回复12
  • 已保存回复12
  • 发布时间2024/4/20 21:55
  • 上次更新2024/4/21 08:26:12
查看原帖
为什么G题暴力能过?
576448
aulive楼主2024/4/20 21:55

rt

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn=1e5;
ll n,m;
ll a,b,c;
vector <int> rood[maxn+5];
int ton[maxn+5];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	int lastans=0;
	for(int i=1;i<=m;i++){
		cin>>a>>b>>c;
		a=(a*(1+lastans)%998244353)%2+1;
		b=(b*(1+lastans)%998244353)%n+1;
		c=(c*(1+lastans)%998244353)%n+1;
//		cout<<a<<" "<<b<<" "<<c<<"\n";
		if(a==1){
			rood[b].push_back(c);
			rood[c].push_back(b);
		}else{
			lastans=0;
			int now=b;
			for(int to:rood[now]){
				ton[to]=1;
			}
			now=c;
			for(int to:rood[now]){
				if(ton[to]){
					lastans=to;
					break;
				}
			}
			memset(ton,0,sizeof(ton));
			cout<<lastans<<"\n";
		}
	}
	return 0;
}
2024/4/20 21:55
加载中...