D. Green and Black Tea

先搞多的,搞到相等。

(tmd上星期+上上星期简直是弱智,怎么也不会写,总是想着各种a/b,,,踢蹬)

#include<bits/stdc++.h>
#define lowbit(x) x&(-x) 
#define LL long long 
#define N 200005
#define M 1000005
#define mod 2147483648LL
#define inf 0x7ffffffff
using namespace std;
inline int ra()
{
    int x=0,f=1; char ch=getchar();
    while (ch<'0' || ch>'9'){if (ch=='-') f=-1; ch=getchar();}
    while (ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
bool ans[N];
int cnt;
int main()
{
    int n=ra(),k=ra(),a=ra(),b=ra();
    bool last=0;
    int nn=n;
    if (a>b) last=1; 
    int tot=0;
    while (n--)
    {
        if (tot<k)
        {
            if (a>b) tot++,a--,ans[++cnt]=1,last=1;
                else tot++,b--,ans[++cnt]=0,last=0;
            if (a==b) break;
        }
        else 
        {
            if (last) ans[++cnt]=0,last^=1,b--;
                else ans[++cnt]=1,last^=1,a--;
            tot=0;
        }
        if (a<0 || b<0)
        {
            cout<<"NO";
            return 0;
        }
    }
    for (int i=1; i<=n; i++)
        if (last) ans[++cnt]=0,last^=1;
            else ans[++cnt]=1,last^=1;
    for (int i=1; i<=nn; i++)
        if (ans[i]) cout<<"G";
            else cout<<"B";
    return 0;
}
//原来死都做不出来,看起来是淡定啊。。。2333
//不知道怎么搞CSDN表示尴尬2333 

 

posted @ 2017-01-06 21:06  ws_ccd  阅读(151)  评论(0编辑  收藏  举报