QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408877#7738. Equivalent RewritingzrzringWA 1ms3500kbC++201.6kb2024-05-11 10:24:012024-05-11 10:24:01

Judging History

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

  • [2024-05-11 10:24:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3500kb
  • [2024-05-11 10:24:01]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

#define endl '\n'
#define PII std::pair<i64, i64>
#define NO return (void)(std::cout << "NO" << endl)
#define YES return (void)(std::cout << "YES" << endl)
#define Fast_IOS std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0)

const i64 mod = 998244353;

template <class T> void MOD(T &x) {x = (x % mod + mod) % mod;}
template <class T> T lg(T x) {return (T)log10(x);}
template <class T> T log(T x) {return (T)log2(x);}
template <class T> T abs(T x) {return x < 0 ? -x : x;}
template <class T> T mysqrt(T x) {return std::floor(sqrtl(x));}

struct WORK {
	int n, m;

	WORK() {}

	void solve() {
		int n, m;
		std::cin >> n >> m;
		std::vector<std::set<int>> a(n + 1), b(n + 1);
		for (int i = 1; i <= n; i++) {
			int p;
			std::cin >> p;
			while (p--) {
				int x;
				std::cin >> x;
				a[i].insert(x);
			}
		}
		std::vector<int> last(m + 1);
		for (int i = n; i >= 1; i--) {
			for (auto x : a[i]) {
				if (!last[x]) last[x] = i;
			}
		}
		for (int i = 1; i <= m; i++) {
			if (last[i] <= 1) continue;
			int j = last[i];
			if (a[j - 1].find(i) == a[j - 1].end()) {
				std::cout << "Yes" << endl;
				std::vector<int> ans(n + 1);
				std::iota(ans.begin(), ans.end(), 0);
				std::swap(ans[i - 1], ans[i]);
				for (int i = 1; i <= n; i++) {
					std::cout << ans[i] << " \n"[i == n];
				}
				return;
			}
		}
		std::cout << "No" << endl;
	}
};

int main() {
	Fast_IOS;
	WORK work;
	int T = 1;
	std::cin >> T;
	while (T--) {
		work.solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3500kb

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

result:

wrong answer two transactions are not equivalent. (test case 1)