QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#730902 | #7738. Equivalent Rewriting | Jun666 | WA | 0ms | 3560kb | C++20 | 1.3kb | 2024-11-09 22:19:04 | 2024-11-09 22:19:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i128=__int128_t;
#define int long long
void solve(){
int n,m;
cin>>m>>n;
vector<vector<int>>p(m+1);
vector<vector<int>>pp(m+1);
vector<int>last(n+1,0);
for(int i=1;i<=m;i++){
int x;
cin>>x;
for(int j=0;j<x;j++){
int index;
cin>>index;
p[i].push_back(index);
pp[i].push_back(last[index]);
last[index]=i;
}
}
for(int i=m;i>=1;i--){
int mx=0;
for(size_t j=0;j<pp[i].size();j++){
mx=max(mx,pp[i][j]);
}
if(mx<i-1){
cout<<"Yes"<<'\n';
for(int j=1;j<=m;j++){
if(j==i-1) cout<<i<<" \n"[j==m];
else if(j==i) cout<<i-1<<" \n"[j==m];
else cout<<j<<" \n"[j==m];
}
return ;
}
}
cout<<"No"<<"\n";
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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 1 3 2 No No
result:
ok OK. (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3560kb
input:
1 10 5 2 2 4 4 1 3 4 2 1 2 3 2 1 4 4 5 2 4 3 3 2 5 4 3 5 4 2 3 1 3 2 5 1 4 2 3 5 1 4
output:
No
result:
wrong answer jury found an answer but participant did not (test case 1)