其他分享
首页 > 其他分享> > 【HDOJ6684】Rikka with Game(博弈)

【HDOJ6684】Rikka with Game(博弈)

作者:互联网

题意:有一个由小写字母组成的字符串,A和B两个人轮流操作,A想让序列的字典序最大,B想最小

两人都能任意选择一位上的字母将其右移一位(a->b,b->c……z->a)或者直接结束游戏

A先手操作,问最后的序列

n<=1e2

思路:

 

 

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 typedef unsigned int uint;
 5 typedef unsigned long long ull;
 6 typedef pair<int,int> PII;
 7 typedef pair<ll,ll> Pll;
 8 typedef vector<int> VI;
 9 typedef vector<PII> VII;
10 #define N  310000
11 #define M  4100000
12 #define fi first
13 #define se second
14 #define MP make_pair
15 #define pi acos(-1)
16 #define mem(a,b) memset(a,b,sizeof(a))
17 #define rep(i,a,b) for(int i=(int)a;i<=(int)b;i++)
18 #define per(i,a,b) for(int i=(int)a;i>=(int)b;i--)
19 #define lowbit(x) x&(-x)
20 #define Rand (rand()*(1<<16)+rand())
21 #define id(x) ((x)<=B?(x):m-n/(x)+1)
22 #define ls p<<1
23 #define rs p<<1|1
24 
25 const ll MOD=1e9+7,inv2=(MOD+1)/2;
26       double eps=1e-6;
27       int INF=1e9;
28       int da[4]={-1,1,0,0};
29       int db[4]={0,0,-1,1};
30 
31       char ch[N];
32 
33 int read()
34 {
35    int v=0,f=1;
36    char c=getchar();
37    while(c<48||57<c) {if(c=='-') f=-1; c=getchar();}
38    while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
39    return v*f;
40 }
41 
42 
43 int main()
44 {
45     //freopen("1.in","r",stdin);
46     //freopen("1.out","w",stdout);
47 
48     int cas;
49     scanf("%d",&cas);
50 
51     while(cas--)
52     {
53         scanf("%s",ch+1);
54         int n=strlen(ch+1);
55         rep(i,1,n)
56         {
57             if(ch[i]=='y') continue;
58             if(ch[i]=='z') ch[i]='b';
59             break;
60         }
61         rep(i,1,n) printf("%c",ch[i]);
62         printf("\n");
63     }
64 
65     return 0;
66 }

 

标签:typedef,int,unsigned,long,HDOJ6684,Game,pair,Rikka,define
来源: https://www.cnblogs.com/myx12345/p/11666741.html