Codeforces 1221 E Game With String

Face questions

 

   At first glance I thought it was SG title function to find the law, and the findings are not fair game. . . .

   But later I thought, in fact, it is better to do.

 

    One obvious feature of this game is the length of time any ∈ [b, a) when the blocks present on the spot, Bob win. (Consider greedy)

    The key to this problem is found, if there Bob operating field length> = block 2b, then the win and Bob, Bob at this time may be constructed as a block of length b.

 

    The rest is the rest of violence with different situations, it seems that the idea has been clear, but the details are more violent. . . . Left to your own thinking about it w

 

#include<bits/stdc++.h>
#define ll long long
using namespace std;

inline int read(){
	int x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar());
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x;
} 

bool fl;

inline int Get(){
	int x=0; char ch=getchar();
	for(;ch=='.';ch=getchar()) x++;
	if(ch=='\n') fl=1;
	return x;
}

int Q,a,b,now;

inline bool solve(){
	a=read(),b=read();
	
	int BA=0,BB=0,DB=0,mx=0;
	for(fl=0;!fl;) now=Get(),BA+=now>=a,BB+=now>=b,DB+=now>=b*2,mx=max(mx,now);
	
	if(BB>BA) return 0;
	if(a>=2*b) return BA==1&&mx<=a+2*b-2;
	IF (MX> A +. 4 * B-2 || DB>. 1) return 0; 
	IF (DB) return ((BA &. 1) && (MX> =. 3 * A || MX <= A + 2 * B-2) ) || && MX> = 2 * A && MX <= A +. 3 * B-2) ((BA &. 1!); 
	return BA &. 1; 
} 

int main () { 
	for (Q = Read (); Q; Q -) the puts ( ? Solve () "YES": "NO"); 
	return 0; 
} 

/ * 
    [B, a) 
    ! turn Bob long time operation, the presence of field> = block 2b, then Bob win 
	
	1.A> = 2b more miserable Thus, all <b Alice only after the first time fill and fill out 
	
	2.a∈ [b + 1,2b-1] normally, if there is only one spot and only> = 2b of and len <= A + 4B-2 
	
* /

  

Guess you like

Origin www.cnblogs.com/JYYHH/p/11566607.html