QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#673915#7738. Equivalent RewritingciyekuaWA 0ms3776kbC++231.2kb2024-10-25 11:44:312024-10-25 11:44:32

Judging History

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

  • [2024-10-25 11:44:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2024-10-25 11:44:31]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define int long long
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define ff first
#define ss second
#define bb begin()
#define ee end()
#define pii pair<int,int>
using namespace std;
void solve()
{
	int n,m;cin>>n>>m;
	vvi b(n+1);
	bool suc=false;
	int cur=0;
	vi p(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
		b[i].resize(p[i]+1);
		for(int j=1;j<=p[i];j++) cin>>b[i][j];
	}
	for(int i=1;i<=n;i++)
	{
		bool f=false;
		if(i==1) continue;
		map<int,int> mp1,mp2;
		for(int j=1;j<=max(p[i-1],p[i]);j++)
		{
			if(j<=p[i-1]) mp1[b[i-1][j]]++;
			if(j<=p[i]) mp2[b[i][j]]++;
		}
		for(auto [u,v]:mp2)
		{
			if(mp1[u]) 
			{
				f=true;
			}
		}
		if(!f)
		{
			suc=true;
			cur=i;
			break;
		}
	}
	if(!suc){
		cout<<"No"<<endl;
		return ;
	}
	cout<<"Yes"<<endl;
	for(int i=1;i<cur-1;i++) cout<<i<<' ';
	cout<<cur<<' '<<cur-1;
	for(int i=cur+1;i<=n;i++) cout<<i<<' '; 
	cout<<endl;
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T;cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
1 3 2
No
No

result:

ok OK. (3 test cases)

Test #2:

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

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)