QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619945#7738. Equivalent RewritingMoemi_WA 0ms3608kbC++201.6kb2024-10-07 16:06:532024-10-07 16:06:55

Judging History

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

  • [2024-10-07 16:06:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-10-07 16:06:53]
  • 提交

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 ++)
	{
		bool flag = true;
		for(auto t : a[i]) 
		{
			if(mp[t]) flag = false;
			mp[t] = 1;
		}
		if(flag) 
		{
			cout << "Yes" << endl;
			cout << i + 1 << " ";
			for(int j = 1; j <= n; j ++) 
			{
				if(j - 1 != i) 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: 3608kb

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: 0ms
memory: 3608kb

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)