QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#250223#7738. Equivalent RewritingXHYMathematicsWA 2ms6712kbC++231003b2023-11-12 23:14:292023-11-12 23:14:30

Judging History

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

  • [2023-11-12 23:14:30]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6712kb
  • [2023-11-12 23:14:29]
  • 提交

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)