QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#767683#7738. Equivalent RewritingguangxuautumnWA 0ms3768kbC++14850b2024-11-20 21:43:472024-11-20 21:43:48

Judging History

This is the latest submission verdict.

  • [2024-11-20 21:43:48]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3768kb
  • [2024-11-20 21:43:47]
  • Submitted

answer

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

const int N = 1e5+7;
int val[N];


void solve()
{
	int n, m;
	cin >> n >> m;
	
	vector<vector<int>> b(n+1);
	for (int i = 1; i <= n; ++i)
	{
		int p;
		cin >> p;
		while (p--)
		{
			int x;
			cin >> x;
			b[i].push_back(x);
		}
	}
	
	for (int i = 1; i < n; ++i)
	{
		set<int> s;
		for (auto v : b[i]) s.insert(v);
		for (auto v : b[i+1]) s.insert(v);
		
		if (s.size() == b[i].size() + b[i+1].size())
		{
			cout << "Yes\n";
			for (int j = 1; j <= n; ++j)
			{
				if (j == i) cout << i+1 << " ";
				else if (j == i + 1) cout << i << " ";
				else cout << j << " ";
			}
			cout << "\n";
			return;
		}
	}
	
	
	cout << "No\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.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: 3768kb

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

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)