20分求救,样例没过,用的队列
查看原帖
20分求救,样例没过,用的队列
662953
_ZXWDS楼主2022/10/11 08:48
#include<bits/stdc++.h>
using namespace std;
queue<int> q;
queue<int> p;
int n,x,y,A,B;
int a[2010],b[2010];
int c[5][5] = {{0,0,1,1,0},{1,0,0,1,0},{0,1,0,0,1},{0,0,1,0,1},{1,1,0,0,0}};

int main(){
	cin>>n>>x>>y;
	for(int i=1;i<=x;i++){
		cin>>a[i];
		q.push(a[i]);
	}
	for(int i=1;i<=y;i++){
		cin>>b[i];
		p.push(b[i]);
	}
	while(n--){
		int x = q.front();
		q.pop();
		int y = p.front();
		p.pop();
		A+=c[x-1][y-1];
		B+=c[y-1][x-1];
		q.push(x);
		p.push(y);
	}
	cout<<A<<" "<<B<<endl;
	return 0;
} 
2022/10/11 08:48
加载中...