QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#667000#7738. Equivalent RewritingE_REMALWA 0ms3612kbC++14727b2024-10-22 20:43:292024-10-22 20:43:45

Judging History

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

  • [2024-10-22 20:43:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-10-22 20:43:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int last[maxn],p[maxn];
int n,m,t,loc;
bool b,ans;
int s,e;
int main()
{
	cin>>t;
	while(t--) {
		cin>>n>>m;
		for(int i=1;i<=m;i++) last[i]=0;
		ans=0;		
		s=0;
		e=0;
		for(int i=1;i<=n;i++) {
				cin>>p[i];
				b=1;
				for(int j=1;j<=p[i];j++) {
					cin>>loc;
					p[last[loc]]--;
					if(i-last[loc]==1) b=0;
					last[loc]=i;
				}
				if(b==1) {
					s=i-1;
					e=i;
					ans=1;
				}
		}
		if(ans) {
			cout<<"Yes"<<endl;
			for(int i=1;i<=n;i++) {
				if(i==s) cout<<e;
				else if(i==e) cout<<s;
				else cout<<i;
				if(i!=n) cout<<' ';
			}
			cout<<endl;
		}
		else cout<<"No"<<endl;
	}		
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

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: 3564kb

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)