QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#546548#7738. Equivalent RewritingyulishenWA 0ms3828kbC++201.1kb2024-09-04 09:07:212024-09-04 09:07:23

Judging History

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

  • [2024-09-04 09:07:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3828kb
  • [2024-09-04 09:07:21]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
int ans[maxn];
void solve()
{
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	for (int i = 1; i <= m; i++)
	{
		a[i] = 0;
	}
	for (int i = 1; i <= n; i++)
	{
		ans[i] = 0;
	}
	for (int i = 1; i <= n; i++)
	{
		int k;
		cin >> k;
		for (int j = 1; j <= k; j++)
		{
			int x;
			cin >> x;
			ans[i] = max(ans[i], a[x]);
			a[x] = i;
		}
	}
	// for (int i = 1; i <= n; i++)
	// {
	// 	cout << ans[i] << " ";
	// }
	// cout << endl;
	int flag = 0;
	for (int i = 2; i <= n; i++)
	{
		if (ans[i] != i - 1)
		{
			flag = i;
			break;
		}
	}
	if (flag == 0)
	{
		cout << "No" << endl;
		return ;
	}
	cout << "Yes" << endl;
	for (int i = 1; i <= n; i++)
	{
		if (i != 1) cout << " ";
		if (i == flag - 1)
		{
			cout << i + 1;
		}
		else if (i == flag)
		{
			cout << i - 1;
		}
		else
		{
			cout << i;
		}
	}
	cout << endl;
	return ;
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

详细

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

result:

ok OK. (3 test cases)

Test #2:

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

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)