1042 Shuffling Machine题解
因为每一趟的顺序改变,都只是下标的改变,其值不会发生变换,以空间换时间
1、把下标值index和card的值存放在一个结构体中
2、每一趟将结构体中的index更新
3、以index从小到大的顺序 sort()结构体
4、重复第一步,操作次数为k
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int order[54];
struct node
{
int v;
int pos;
}card[54];
bool cmp(node a,node b)
{
return a.pos<b.pos;
}
string getName(<