QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#229267#7640. Colorful Cyclesucup-team266#WA 126ms84628kbC++142.2kb2023-10-28 15:37:002023-10-28 15:37:01

Judging History

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

  • [2024-07-04 22:58:32]
  • hack成功,自动添加数据
  • (/hack/728)
  • [2023-10-28 15:37:01]
  • 评测
  • 测评结果:WA
  • 用时:126ms
  • 内存:84628kb
  • [2023-10-28 15:37:00]
  • 提交

answer

/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
 
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts 
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest

9. module on time 
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
int dfn[1000005],low[1000005],stk[1000005],top,times;
vector <int> ans[1000005];
int bcccnt=0;
int rt; // dfs 树起点 
bool cut[1000005];
vector <int> g[1000005];
int mask[1000005],bl[1000005];
map <pii,int> col;
void tarjan(int u)
{
	dfn[u]=low[u]=++times;
	stk[++top]=u;
	if(u==rt&&!g[u].size())
	{
		bcccnt++;
		ans[bcccnt].pb(u);
		return;
	}
	int flg=0;
	for(int i=0;i<g[u].size();i++)
	{
		int v=g[u][i];
		if(!dfn[v])
		{
			tarjan(v);
			low[u]=min(low[u],low[v]);
			if(low[v]>=dfn[u])
			{
				flg++;
				if(u!=rt||flg>1) cut[u]=1;
				bcccnt++;
				int x;
				ans[bcccnt].pb(u);
				bl[u]=bcccnt;
				do
				{
					x=stk[top],top--;
					ans[bcccnt].pb(x);
					bl[x]=bcccnt;
				}while(x!=v);
				
			}
		}
		else low[u]=min(low[u],dfn[v]);
	}
}
int n,m;
vector <pii > h[1000005];
void solve()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) g[i].clear(),h[i].clear(),dfn[i]=low[i]=stk[i]=cut[i]=mask[i]=bl[i]=0,ans[i].clear();
	top=times=bcccnt=0;
	while(m--)
	{
		int u,v,w;
		cin>>u>>v>>w;
		g[u].pb(v),g[v].pb(u);
		h[u].pb(mp(v,w)),h[v].pb(mp(u,w));
	}
	rt=1,tarjan(1);
	for(int i=1;i<=n;i++) for(int j=0;j<g[i].size();j++)
	{
		int v=h[i][j].fi,w=h[i][j].se;
		if(cut[i]) mask[bl[v]]|=(1<<w);
		else if(bl[i]==bl[v]) mask[bl[i]]|=(1<<w);
	}
	for(int i=1;i<=bcccnt;i++) if(mask[i]==14) 
	{
		cout<<"Yes\n";
		return;
	}
	cout<<"No\n";
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int _=1;
	cin>>_;
	while(_--) solve();
	return 0;
} 

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 83968kb

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: 126ms
memory: 84628kb

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
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
...

result:

wrong answer expected NO, found YES [131st token]