QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#250238#7738. Equivalent RewritingXHYMathematicsWA 2ms8268kbC++231.1kb2023-11-12 23:47:482023-11-12 23:47:48

Judging History

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

  • [2023-11-12 23:47:48]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8268kb
  • [2023-11-12 23:47:48]
  • 提交

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)