QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770562#7738. Equivalent Rewritings1ameseWA 0ms3756kbC++20926b2024-11-21 22:22:282024-11-21 22:22:28

Judging History

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

  • [2024-11-21 22:22:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3756kb
  • [2024-11-21 22:22:28]
  • 提交

answer

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

void solve() {
	int n, m;
	cin >> n >> m;

	vector<vector<int>> a(n);
	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;
		a[i].resize(p);
		for (int j = 0; j < p; j++)
			cin >> a[i][j], a[i][j]--;
	}

	vector<int> col(n);

	for (int i = n - 1; i >= 0; i--) {
		bool ok = true;
		for (int j = 0; j < a[i].size(); j++)
			if (!col[a[i][j]]) {
				col[a[i][j]] = i + 1;
			} else if (col[a[i][j]] == i + 2) {
				ok = false;
			}
		if (ok && i != n - 1) {
			cout << "Yes\n";
			for (int j = 0; j < i; j++)
				cout << j + 1 << " ";
			cout << i + 2 << " " << i + 1;
			if (i < m - 2) {
				cout << " ";
				for (int j = i + 2; j < n; j++) {
					cout << j + 1;
					if (j < n - 1)
						cout << " ";
				}
			}
			cout << '\n';
			return;
		}
	}

	cout << "No\n";
}

int main() {
	int t;
	cin >> t;

	while (t--)
		solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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:

Yes
1 2 3 4 5 6 8 7

result:

wrong output format Unexpected end of file - int32 expected (test case 1)