QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619971#7738. Equivalent RewritingMoemi_WA 1ms3632kbC++201.8kb2024-10-07 16:11:222024-10-07 16:11:27

Judging History

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

  • [2024-10-07 16:11:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3632kb
  • [2024-10-07 16:11:22]
  • 提交

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);
	for(int i = 0; i < n; i ++)
	{
		cin >> k;
		while(k -- )
		{
			int x;
			cin >> x;
			a[i].pb(x);
		}
		sort(a[i].begin(), a[i].end());
		a[i].erase(unique(a[i].begin(), a[i].end()), a[i].end());
	}
	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[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;
			for(int j = 1; j <= n; j ++)
			{
				if(j == i + 1) cout << i << " ";
				else if(j == i) cout << i + 1 << " ";
				else 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: 100
Accepted
time: 0ms
memory: 3564kb

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

result:

ok OK. (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3632kb

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 7 9 8 10 

result:

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