QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#620105#7738. Equivalent RewritingMoemi_WA 0ms3860kbC++202.1kb2024-10-07 16:39:412024-10-07 16:39:42

Judging History

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

  • [2024-10-07 16:39:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3860kb
  • [2024-10-07 16:39:41]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <numeric>
 
#define sc_int(x) scanf("%d", &x)
 
#define x first
#define y second
#define pb push_back

using namespace std;

const int N = 5010, M = 10010, MOD = 1e9 + 7;
const int inf = 1e9;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef pair<char, int> PCI;
typedef pair<string, string> PSS;

LL n, m, k;

void solve() 
{
	cin >> n >> m;
	vector<vector<int>> a(n);
	map<vector<int>, vector<int>> mp1;
	for(int i = 0; i < n; i ++)
	{
		cin >> k;
		string t;
		while(k -- )
		{
			int x;
			cin >> x;
		}
		sort(a[i].begin(), a[i].end());
		a[i].erase(unique(a[i].begin(), a[i].end()), a[i].end());
		mp1[a[i]].pb(i);
	}
	
	for(auto [x, y] : mp1)
	{
		if(y.size() > 1)
		{
			cout << "Yes" << endl;
			int t1 = y[0] + 1, t2 = y[1] + 1;
			for(int i = 1; i <= n; i ++) 
			{
				if(i == t1) cout << t2 << " ";
				else if(i == t2) cout << t1 << " ";
				else cout << i << " ";
			}
			return;
		}
	}
	
	map<int, int> mp;
	for(auto t : a[0]) mp[t] = 1;
	for(int i = 1; i < n; i ++)
	{
		int cnt = 0;
		for(auto t : a[i]) 
		{
			if(mp.count(t)) cnt ++;
			mp[t] = 1;
		}
		if(!cnt) 
		{
			cout << "Yes" << endl;
			cout << i + 1 << " ";
			for(int j = 1; j <= n; j ++) 
			{
				if(j - 1 != i) cout << j << " ";
			}
			cout << endl;
			return;
		}
		else if(cnt == mp.size())
		{
			cout << "Yes" << endl;
			cout << 2 << " " << 1 << " ";
			for(int j = 3; j <= n; j ++)
			{
				cout << j << " ";
			}
			cout << endl;
			return;
		}
	}
	cout << "No" << endl;
}


int main()
{
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
     
    int T = 1;
    cin >> T;
    while(T --)
    {
        solve();
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3860kb

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

result:

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