QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#526897#7738. Equivalent RewritingStelorWA 0ms3596kbC++20790b2024-08-22 00:36:552024-08-22 00:36:55

Judging History

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

  • [2024-08-22 00:36:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-08-22 00:36:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

void solve()
{
	int n,m;
	std::cin>>n>>m;
	vector<vector<int>> a(n+1);
	vector<int> cnt(m+10),vis(m+10);
	for(int i=1;i<=n;++i)
	{
		int p;
		cin>>p;
		while(p--)
		{
			int x;cin>>x;
			cnt[x]++;
			a[i].push_back(x);
		}
	}
	if(n==1)
	{
		cout<<"No\n";return;
	}
	int l=0;
	for(int i=n;i>=1;--i)
	{
		bool f=true;
		for(auto j:a[i])
		{
			if(vis[j]||cnt[j]==1)
			{
				l=0;
			}
			else
			{
				f=false;
				break;
			}
		}
		if(f)
		{
			int q=i;
			cout<<"Yes\n";
			cout<<q<<" ";
			for(int i=1;i<=n;++i) if(i!=q) cout<<i<<" ";
			cout<<"\n"; return;
		}
	}
	cout<<"No\n";
}

int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int t;
	cin>>t;
	while(t--) solve();
	return 0;	
}

详细

Test #1:

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

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: 3596kb

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)