Language: C++

#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<pint,int> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint mo=998244353;
lint zyo(lint x,lint y){
    lint ret=1,a=x;
    while(y>0){
    	if(y%2==1) ret=(ret*a)%mo;
    	a=(a*a)%mo;y/=2;
    }
    return ret;
}
int ta[100100],pa[100100];
vector<pint> gr[100100];
map<pint,int> me;
vector<tint> v;
int ng=0;
lint rank;
void dfs(int x,int y,int w){
	if(pa[x]>=0){
		if(pa[x]!=y) ng=1;
		return;
	}
	if(ta[x]>=0){
		if(ta[x]!=y) ng=1;
		else if(w==0) rank++;
	}
	pa[x]=y;
	rep(i,gr[x].size()){
		int z=gr[x][y].fi;
		dfs(z,y^gr[x][y].se,0);
	}
}
lint cal()
{
	memset(ta,-1,sizeof(ta));
	memset(pa,-1,sizeof(pa));
	int n,m,a,b,c;//cin>>n>>m;
	//cout<<rank<<endl;
	cin>>n>>m;
	rank=(lint)n*(n+1)/2;
	rep(i,m){
		cin>>a>>b>>c;a--;b--;
		//cout<<a<<b<<c<<endl;
		if(a==b){
			if(ta[a]<0){
				//cout<<a<<endl;
				rank--;ta[a]=c;
			}
			else if(ta[a]!=c){
				return 0;
			}
		}
		else{
			if(me.count(mp(b,a))>0){
				//v.pb(mp(mp(a,b),c+me[mp(b,a)]));
				int d=c^me[mp(b,a)];
				if(abs(a-b)>2){
					if(d>0) return 0;
				}
				else if(abs(a-b)==2){
					if(ta[(a+b)/2]<0){
						rank--;ta[(a+b)/2]=d;
					}
					else if(ta[(a+b)/2]!=d){
						return 0;
					}
				}
				else{
					gr[a].pb(mp(b,d));gr[b].pb(mp(a,d));rank--;
				}
			}
			else{
				//cout<<a<<b<<endl;
				me[mp(a,b)]=c;rank--;
			}
		}
	}
	//rep(i,n) cout<<ta[i]<<endl;
	rep(i,n){
		if(ta[i]>=0) dfs(i,ta[i],1);
	}
	//cout<<rank<<endl;
	if(ng>0) return 0;
	return zyo(2,rank);
}
int main()
{
	cout<<cal()<<endl;
}


Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:60:31: error: reference to 'rank' is ambiguous
   60 |                 else if(w==0) rank++;
      |                               ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/vector:62,
                 from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:52:6: note:                 'lint rank'
   52 | lint rank;
      |      ^~~~
a.cc: In function 'lint cal()':
a.cc:75:9: error: reference to 'rank' is ambiguous
   75 |         rank=(lint)n*(n+1)/2;
      |         ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:52:6: note:                 'lint rank'
   52 | lint rank;
      |      ^~~~
a.cc:82:33: error: reference to 'rank' is ambiguous
   82 |                                 rank--;ta[a]=c;
      |                                 ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:52:6: note:                 'lint rank'
   52 | lint rank;
      |      ^~~~
a.cc:97:49: error: reference to 'rank' is ambiguous
   97 |                                                 rank--;ta[(a+b)/2]=d;
      |                                                 ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:52:6: note:                 'lint rank'
   52 | lint rank;
      |      ^~~~
a.cc:104:77: error: reference to 'rank' is ambiguous
  104 |                                         gr[a].pb(mp(b,d));gr[b].pb(mp(a,d));rank--;
      |                                                                             ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:52:6: note:                 'lint rank'
   52 | lint rank;
      |      ^~~~
a.cc:109:47: error: reference to 'rank' is ambiguous
  109 |                                 me[mp(a,b)]=c;rank--;
      |                                               ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:52:6: note:                 'lint rank'
   52 | lint rank;
      |      ^~~~
a.cc:119:22: error: reference to 'rank' is ambiguous
  119 |         return zyo(2,rank);
      |                      ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:52:6: note:                 'lint rank'
   52 | lint rank;
      |      ^~~~