QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#250238 | #7738. Equivalent Rewriting | XHYMathematics | WA | 2ms | 8268kb | C++23 | 1.1kb | 2023-11-12 23:47:48 | 2023-11-12 23:47:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll N=1e5;
vector<ll>a[N];
ll pre[N+1];
ll last[N+1];
ll ans[N];
ll n;
inline ll solve()
{
ll i,xmax;
for(i=1;i<n;i++)
{
xmax=0;
for(auto&&j:a[i])
{
if(last[j]==i)xmax=max(xmax,pre[j]);
pre[j]=i+1;
}
if(xmax<i)return i;
}
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],last[a[i][j]]=i;
}
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(pre+1,0,m*sizeof(ll));
memset(last+1,0,m*sizeof(ll));
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 8268kb
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)