QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#249640#7640. Colorful CyclesmanizareWA 145ms79688kbC++141.8kb2023-11-12 13:41:342023-11-12 13:41:35

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 22:58:32]
  • hack成功,自动添加数据
  • (/hack/728)
  • [2023-11-12 13:41:35]
  • 评测
  • 测评结果:WA
  • 用时:145ms
  • 内存:79688kb
  • [2023-11-12 13:41:34]
  • 提交

answer

#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second 
#define all(a) a.begin(),a.end()
#define pii pair <int,int>
#define PII pair<pii , pii>
#define sz(v) (int)v.size()
using namespace std ;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 1e6 + 10 , inf  = 1e8 , lg = 21 ;  
int dis[maxn], mark[maxn] , sb[maxn] ,  c[maxn] , cnt = 1 ;
map <int ,int> mp[maxn] ;vector <int> vec; 
vector <int> G[maxn];
void d1(int v , int p){
	sb[v] = dis[v];mark[v] = 1; 
	for(int u : G[v]){
		if(u == p)continue;
		if(mark[u] == 1){
			sb[v] = min(sb[v] , dis[u]) ;
			continue ;
		}
		dis[u] = dis[v] + 1 ; 
		int ls = vec.back() ;
		d1(u ,v);
		sb[v] = min(sb[v] , sb[u]) ;
		if(sb[u] == dis[v]){
			while(vec.back()!=ls){
				c[vec.back()] = cnt ;
				vec.pop_back();
			}
			cnt++;
		}
	}
	if(dis[v] != sb[v])vec.pb(v);
}

signed main(){ 
  	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) ;
	int T ;
	cin >> T ;
	while(T--){
		int n , m ;
		cin >> n >> m ;vec.clear(); cnt = 1; 
		vector <pair <pii, int> > ed; 
		for(int i = 1; i <= m; i++){
			int v , u , c;
			cin >> v >> u >> c;
			G[v].pb(u);
			G[u].pb(v); 
			ed.pb({{v,u},c});
		}
		vec.pb(0);
		d1(1, 0) ;
		for(auto a : ed){
			if(dis[a.F.F]<dis[a.F.S])swap(a.F.F , a.F.S); 
			if(dis[a.F.F] == sb[a.F.F])continue ;
			mp[c[a.F.F]][a.F.F] |= (1<<(a.S-1)) ;
			mp[c[a.F.F]][a.F.S] |= (1<<(a.S-1)) ;
		}
		bool ok = 0 ;
		for(int i =1; i < cnt ; i++){
			int ted= 0 , x = 0 ;;
			for(pii a : mp[i]){
				if(__builtin_popcount(a.S) >= 2){ted++;}
				x |= a.S ; 
			}
			if(ok == 0 && ted >= 3 && x == 7){cout << "Yes\n";ok = 1 ;}
		}
		if(ok==0) cout << "No\n";
		for(int i = 1; i < cnt ; i++){
			mp[i].clear() ;
		}
		for(int i = 1; i <= n; i++){
			G[i].clear();
		}
	}
}
/* 
 
 
*/

详细

Test #1:

score: 100
Accepted
time: 14ms
memory: 79688kb

input:

2
3 3
1 2 3
2 3 1
1 3 2
5 6
1 2 1
2 3 1
1 3 2
3 4 3
3 5 3
4 5 3

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #2:

score: -100
Wrong Answer
time: 145ms
memory: 78852kb

input:

100000
7 10
7 2 2
6 4 2
6 1 2
7 1 3
3 4 1
6 7 1
2 6 3
3 1 2
5 3 1
2 1 1
7 10
5 7 3
7 1 1
4 6 3
6 3 1
3 4 3
4 2 2
3 2 3
1 3 3
3 7 1
1 4 2
7 10
5 6 3
3 5 2
7 2 3
7 3 3
1 2 2
4 3 2
7 4 2
6 1 2
2 6 1
7 5 2
7 10
7 1 3
7 5 3
6 4 1
7 6 1
1 4 1
3 4 2
2 7 2
1 3 1
3 5 3
5 1 3
7 10
6 7 2
3 4 3
1 4 2
5 3 2
7 4 ...

output:

Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No...

result:

wrong answer expected YES, found NO [2nd token]