QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#250223 | #7738. Equivalent Rewriting | XHYMathematics | WA | 2ms | 6712kb | C++23 | 1003b | 2023-11-12 23:14:29 | 2023-11-12 23:14:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll N=1e5;
vector<ll>a[N];
ll last[N];
ll ans[N];
ll n;
inline ll solve()
{
ll i,xmax;
for(i=0;i<n;i++)
{
xmax=0;
for(auto&&j:a[i])
{
xmax=max(xmax,last[j]+1);
last[j]=i;
}
if(i&&xmax)return xmax;
}
return 0;
}
int main()
{
ll t,m,k,i,j,di;
ios::sync_with_stdio(0),cin.tie(0);
cin>>t;
while(t--)
{
cin>>n>>m;
for(i=0;i<n;i++)
{
cin>>k,a[i].resize(k);
for(j=0;j<k;j++)cin>>a[i][j];
}
di=solve();
if(di)
{
cout<<"Yes\n";
iota(ans,ans+n,1);
swap(ans[di-1],ans[di]);
for(i=0;i<n;i++)cout<<ans[i]<<" \n"[i==n-1];
}
else cout<<"No\n";
for(i=0;i<n;i++)a[i].clear();
memset(last+1,0,n*sizeof(ll));
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 6712kb
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)