QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#325402#7738. Equivalent Rewriting275307894a#WA 2ms10644kbC++141.7kb2024-02-11 09:52:402024-02-11 09:52:41

Judging History

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

  • [2024-02-11 09:52:41]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:10644kb
  • [2024-02-11 09:52:40]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=2e5+5,M=N*4+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
}using namespace Debug;
int n,m,A[N],len[N],ti[N];vector<int> S[N];
void print(int x){
	puts("Yes");
	for(int i=1;i<=m;i++){
		if(i==x) printf("%d",x+1);
		else if(i==x+1) printf("%d",x);
		else printf("%d",i);
		printf("%c"," \n"[i==m]);
	}
}
void Solve(){
	int i,j;scanf("%d%d",&m,&n);
	for(i=1;i<=m;i++){
		scanf("%d",&len[i]);
		S[i].clear();S[i].resize(len[i]);
		for(j=0;j<len[i];j++) scanf("%d",&S[i][j]),A[S[i][j]]=j+1;
	}
	fill(ti+1,ti+n+1,0);
	for(i=m;i;i--){
		int mi=INF;
		for(j=0;j<len[i];j++){
			if(A[S[i][j]]^j+1) mi=min(mi,ti[S[i][j]]);
			else {
				if(!ti[S[i][j]]) ti[S[i][j]]=i;
			}
		} 
		if(i^m&&mi>i+1) return print(i);
	}
	puts("No");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 10428kb

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: 0
Accepted
time: 2ms
memory: 10588kb

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:

Yes
1 2 3 4 5 6 8 7 9 10

result:

ok OK. (1 test case)

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 10644kb

input:

1
20 5
5 4 1 2 5 3
2 5 3
3 5 1 2
5 4 5 1 3 2
3 4 2 5
5 3 1 5 4 2
5 5 1 2 3 4
1 3
4 5 1 2 3
4 4 1 3 5
2 5 2
4 2 3 5 1
3 2 4 5
5 2 3 4 1 5
4 5 2 4 3
1 2
2 4 3
4 4 5 3 1
5 4 1 5 3 2
3 5 1 3

output:

Yes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 18 20

result:

wrong answer two transactions are not equivalent. (test case 1)