???Codeforces Round #482 (Div. 2) B???Treasure Hunt

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了???Codeforces Round #482 (Div. 2) B???Treasure Hunt相关的知识,希望对你有一定的参考价值。

?????????pre   span   ring   push   ??????   xxxx   ==   ??????   ??????   

???????????? ????????????,?????????:)
????????????


?????????????????????

????????????


??????????????????????????????????????????????????????????????????cnt[3]
?????????3???cnt?????????
??????cnt+n<=s[i].size
???????????????????????????cnt+n???????????????

????????????cnt+n>s[i].size()
?????????????????????
??????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????

???????????????????????????
?????????????????????????????????????????????????????????
?????????????????????????????????????????????,??????"xxxaxxxx"??????a
??????????????????????????????cnt,??????????????????cnt??????????????????a????????????,??????a,b,c,...?????????????????????????????????x
??????????????????????????????

??????????????????????????????
??????n==1,??????cnt[i]==s[i].size()
?????????????????????????????????
???????????????????????????
(??????????????????????????????????????????????????????
??????????????????s[i].size()-1;

????????????

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f
#define pll pair<ll,ll>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep1(i,a,b) for(int i=a;i>=b;i--)
#define rson rt<<1|1,m+1,r
#define lson rt<<1,l,m
using namespace std;
const int N=1e5+100;
int n,cnt[3],rest[3];
string s[3];
map<char,int> mmap[3];

struct abc{
    string s;
    int num;
}b[3];

bool cmp(abc a,abc b){
    return a.num>b.num;
}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0);
    cin>>n;
    rep(i,0,2) cin >> s[i];
    rep(i,0,2){
        rep(j,0,(int)s[i].size()-1){
            mmap[i][s[i][j]]++;
            cnt[i] = max(cnt[i],mmap[i][s[i][j]]);
        }
    }

    b[0].s = "Kuro";
    b[1].s = "Shiro";
    b[2].s = "Katie";
    rep(i,0,2) {
        if (cnt[i]+n>(int)s[i].size()){
            if (cnt[i]==(int)s[i].size() && n==1) cnt[i] = (int)s[i].size()-1;
            else cnt[i] = (int)s[i].size();
        }else cnt[i] = cnt[i]+n;
        b[i].num = cnt[i];

    }
    sort(b+0,b+0+3,cmp);
    if (b[0].num==b[1].num){
        cout<<"Draw"<<endl;
    }else{
        cout<<b[0].s<<endl;
    }
    return 0;
}

以上是关于???Codeforces Round #482 (Div. 2) B???Treasure Hunt的主要内容,如果未能解决你的问题,请参考以下文章

???Codeforces Round #482 (Div. 2) B???Treasure Hunt

Codeforces Round #482 (Div. 2) C Kuro and Walking Route

Codeforces Round #482 (Div. 2) :B - Treasure Hunt

Codeforces Round #482 (Div. 2) CKuro and Walking Route

Codeforces Round #482 (Div. 2) C Kuro and Walking Route(dfs)979C

Codeforces Round #482 (Div. 2)D. Kuro and GCD and XOR and SUM+字典树