QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#620105 | #7738. Equivalent Rewriting | Moemi_ | WA | 0ms | 3860kb | C++20 | 2.1kb | 2024-10-07 16:39:41 | 2024-10-07 16:39:42 |
Judging History
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)