P2348 三国杀I(洗牌&发牌)

Aimee

模拟即可

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,k,p;
int a[110001];
int b[110001];
struct car{
	string cn;
	string ty;
}c[110001];
void wash(){
	for(int i=1;i<=m;i+=2){
			b[i]=a[(i/2+1)+m/2];
			b[i+1]=a[(i/2+1)];
	}
	for(int i=1;i<=m;++i){
		a[i]=b[i]; 
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&k,&p);
	if(m<4*n){
		cout<<"Error:cards not enough";
		return 0;
	}
	for(int i=1;i<=m;++i){
		a[i]=i;
		b[i]=i;
		cin>>c[i].cn>>c[i].ty;
	}
	m=m/2*2;
	while(k--){
		wash(); 
	} 
	for(int i=1;i<=4*n;++i){
		if(i%n==p)
		cout<<c[a[i]].cn<<" "<<c[a[i]].ty<<endl;
	}
	return 0;
}

posted @ 2021-05-09 21:12  Simex  阅读(179)  评论(0编辑  收藏  举报