QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#269008#7738. Equivalent Rewritingmendicillin2#WA 1ms5992kbC++17962b2023-11-29 10:21:082023-11-29 10:21:08

Judging History

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

  • [2023-11-29 10:21:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5992kb
  • [2023-11-29 10:21:08]
  • 提交

answer

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

const int N=1e5+5;

int n,m;
vector<int> re[N];
int p[N];
int ans[N];
bool vis[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int T;
	cin>>T;
	while(T--)
	{
		cin>>n>>m;
		int c;
		for(int i=1;i<=n;i++)
		{
			cin>>p[i];
			for(int j=1;j<=p[i];j++) 
			{
				cin>>c;
				re[i].push_back(c);
			}
		}
		for(int i=1;i<=n;i++) ans[i]=i;
		int pos=0;
		for(int i=1;i<n;i++)
		{
			bool flag=true;
			for(auto k : re[i+1]) vis[k]=true;
			for(auto k : re[i])
				if(vis[k])
				{
					flag=false;
					break;
				}
			for(auto k : re[i+1]) vis[k]=false;
			if(flag)
			{
				pos=i;
				break;
			}
		}
		if(!pos) cout<<"No"<<"\n";
		else
		{
			swap(ans[pos],ans[pos+1]);
			cout<<"Yes"<<"\n";
			for(int i=1;i<=n-1;i++) cout<<ans[i]<<" ";
			cout<<ans[n]<<"\n";
		}

		// clear
		for(int i=1;i<=n;i++) re[i].clear();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5988kb

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: 1ms
memory: 5992kb

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)