这道题用map可以吗?我只拿了50分
查看原帖
这道题用map可以吗?我只拿了50分
1035926
shenyeting楼主2024/1/29 08:55
#include<bits/stdc++.h>
using namespace std;
map<long long,long long> c;
int main(){
	long long a,b,x,y,z,ans=0;
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>b;
		if(b<1){
			cout<<"NO";
			return 0;
		}
		for(int j=0;j<b;j++){
			cin>>x>>y>>z;
			c[x]++;
			c[y]++;
			if(z==1){
				if(c[x]==c[y]){
					ans++;
				}
			}
			if(z!=0){
				if(c[x]!=c[y]){
					ans++;
				}
			}
		}
		if(ans==b){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
		ans=0;
		//memset(c,0,sizeof(c));
		c.clear();
	}
}
2024/1/29 08:55
加载中...