QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#590275#7738. Equivalent Rewritingbruteforce_WA 0ms3664kbC++20957b2024-09-25 23:02:072024-09-25 23:02:09

Judging History

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

  • [2024-09-25 23:02:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-09-25 23:02:07]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+7,inf=1e18;
void O_o()
{
	int n,m;
	cin>>m>>n;
	vector<int> a(n+1,m+1),d(m+2,0);
	vector e(m+2,vector<int>());
	for(int i=1; i<=m; i++)
	{
		int t;
		cin>>t;
		while(t--)
		{
			int x;
			cin>>x;
			e[a[x]].push_back(i);
			a[x]=i;
			d[i]++;
		}
	}
	priority_queue<int> q;
	q.push(m+1);
	bool bz=0;
	vector<int> ans;
	while(!q.empty())
	{
		int u=q.top(); q.pop();
		if(u<=m) ans.push_back(u);
		for(auto v:e[u])
		{
			d[v]--;
			if(!d[v])
			{
				q.push(v);
			}
		}
		if(q.size()>=2) bz=1;
	}
	if(!bz)
	{
		cout<<"No\n";
		return;
	}
	cout<<"Yes\n";
	for(int i=0; i<ans.size(); i++)
	{
		cout<<ans[i];
		if(i==m-1) cout<<"\n";
		else cout<<" ";
	}
	
}
signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout<<fixed<<setprecision(12);
	int T=1;
	cin>>T;
	while(T--)
	{
		O_o();
	}
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3568kb

input:

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

output:

Yes
3 1 2
No
No

result:

ok OK. (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3664kb

input:

1
10 5
2 2 4
4 1 3 4 2
1 2
3 2 1 4
4 5 2 4 3
3 2 5 4
3 5 4 2
3 1 3 2
5 1 4 2 3 5
1 4

output:

No

result:

wrong answer jury found an answer but participant did not (test case 1)