codeforces补题:979

codeforces 979b:::

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 const int maxn=1e5+100;
 4 int n;
 5 char s[maxn];
 6 int num[100];//Kuro Shiro Katie
 7 int ansl[5];
 8
 9 int solve(){
10     scanf("%s",s+1);
11     memset(num,0,sizeof(num));
12     int len=strlen(s+1);
13     for(int i=1;i<=len;i++){
14         if(s[i]>=‘A‘&&s[i]<=‘Z‘) num[s[i]-‘A‘+1]++;
15         else num[s[i]-‘a‘+27]++;
16     }
17     int mx=0,m=n;
18     for(int i=1;i<=52;i++) mx=max(num[i],mx);
19
20     if(mx+m<=len) return mx+m;
21     else{
22         if(mx==len){
23             if(m==1) return len-1;
24             else return len;
25         }else{
26             return len;
27         }
28     }
29 }
30 int main(){
31     scanf("%d",&n);
32     ansl[1]=solve();
33     ansl[2]=solve();
34     ansl[3]=solve();
35     int mxans=max(ansl[1],max(ansl[2],ansl[3]));
36   //  for(int i=1;i<=3;i++) printf("%d\n",ansl[i]);
37     if((mxans==ansl[1]&&mxans==ansl[2])||(mxans==ansl[2]&&mxans==ansl[3])||(mxans==ansl[1]&&mxans==ansl[3])){
38         printf("Draw\n");
39     }else{
40         if(mxans==ansl[1]){
41             printf("Kuro\n");return 0;
42         }else if(mxans==ansl[2]){
43             printf("Shiro\n");return 0;
44         }else{
45             printf("Katie\n");return 0;
46         }
47     }
48     return 0;
49 }

看了一个红黑大神的代码,感觉差距不知道大到哪儿去了,接下来贴一下这个大神的写法

 1 #include <stdio.h>
 2 #include <algorithm>
 3 #include <assert.h>
 4 #include <bitset>
 5 #include <cmath>
 6 #include <complex>
 7 #include <deque>
 8 #include <functional>
 9 #include <iostream>
10 #include <limits.h>
11 #include <map>
12 #include <math.h>
13 #include <queue>
14 #include <set>
15 #include <stdlib.h>
16 #include <string.h>
17 #include <string>
18 #include <time.h>
19 //#include <unordered_map>
20 //#include <unordered_set>
21 #include <vector>
22
23 #pragma warning(disable:4996)
24 #pragma comment(linker, "/STACK:336777216")
25
26 using namespace std;
27
28 #define mp make_pair
29 #define all(x) (x).begin(), (x).end()
30
31 //typedef tuple<int, int, int> t3;
32 typedef long long ll;
33 typedef unsigned long long ull;
34 typedef double db;
35 typedef long double ldb;
36 typedef pair <int, int> pii;
37 typedef pair <ll, ll> pll;
38 typedef pair <db, db> pdd;
39
40 int IT_MAX = 1 << 18; // segment tree size
41 const ll MOD = 1000000007;
42 const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
43 const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
44 const db PI = acos(-1);
45 const db ERR = 1e-10; // double EPS
46
47 char u[100050];
48
49 int cnt[52];
50 int ch(char c) {
51     if (c >= ‘a‘ && c <= ‘z‘) return c - ‘a‘;
52     return c - ‘A‘ + 26;
53 }
54 int getans(int N) {
55     scanf("%s", u);
56     int i, L = strlen(u);
57     for (i = 0; i < 52; i++) cnt[i] = 0;
58     for (i = 0; i < L; i++) cnt[ch(u[i])]++;
59
60     if (L == 1) return 1;
61
62     int mx = 0;
63     for (i = 0; i < 52; i++) mx = max(mx, cnt[i]);
64
65     if (mx == L) {
66         if (N == 1) return mx - 1;
67         else return mx;
68     }
69
70     return min(L, mx + N);
71 }
72 int main() {
73     int N, i;
74     scanf("%d", &N);
75
76     int v[3];
77     v[0] = getans(N);
78     v[1] = getans(N);
79     v[2] = getans(N);
80
81     int mx = max(max(v[0], v[1]), v[2]);
82
83     int c = 0;
84     for (i = 0; i < 3; i++) if (v[i] == mx) c++;
85     if (c >= 2) return !printf("Draw\n");
86
87     if (v[0] == mx) printf("Kuro\n");
88     if (v[1] == mx) printf("Shiro\n");
89     if (v[2] == mx) printf("Katie\n");
90     return 0;
91 }

这一场因为其他题都没看,所以就暂时鸽了

原文地址:https://www.cnblogs.com/pandaking/p/9742563.html

时间: 2024-08-30 18:34:24

codeforces补题:979的相关文章

Codeforces 补题记录

首先总结一下前段时间遇到过的一些有意思的题. Round #474 (Div. 1 + Div. 2, combined)   Problem G 其实关键就是n这个数在排列中的位置. 这样对于一个排列,设$f[pos] = p$, 那么从位置$1$到位置$pos$最大值被刷新了$a$次,从位置$n$到位置$pos$最大值被刷新了$b$次. 去掉$n$之后,剩下$n-1$个数被分成了两个部分. 假设把这$n-1$个数分成$a+b-2$个组,分配给左边$a-1$个组,给右边$b-1$个组. 对于$

Codeforces补题2020.3.4 (Round620 Div2)

A.Two Rabbits Gildong厌倦了参加过多次Codeforce攻击,决定在公园休息一下.他坐在长凳上,很快他发现两只兔子在跳来跳去.一只兔子比另一只更高. 他注意到两只兔子在互相跳来跳去.两只兔子的位置可以表示为水平线上的整数坐标.较高的兔子当前位于位置x,而较短的兔子当前位于位置y(x <y).每秒钟,每只兔子跳到另一个位置.较高的兔子跳向a的正向,而较短的兔子跳向b的负向. 例如,假设x = 0,y = 10,a = 2和b = 3.在第1秒,每只兔子将在位置2和7.在第2秒,

codeforces 984补题

codeforces 984a 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n; 4 int num[1010]; 5 int main(){ 6 scanf("%d",&n); 7 for(int i=1;i<=n;i++) scanf("%d",&num[i]); 8 sort(num+1,num+n+1); 9 if(n%2==1) printf("%

Codeforces VP/补题小记 (持续填坑)

Codeforces VP/补题小记 1149 C. Tree Generator 给你一棵树的括号序列,每次交换两个括号,维护每次交换之后的直径. ? 考虑括号序列维护树的路径信息和,是将左括号看做 \(-1\) ,右括号看做 \(1\) ,那么一段竖直向上的路径可以表示为括号序列的一个区间和,一段竖直向下的路径可以看做括号序列的一个区间和的相反数.我们要维护的是树的直径,也就是一段连续的和减去紧随其后的一段连续的差.具体来说就是 \[ \max_{\forall [l,r]}\{\sum_{

Educational Codeforces Round 74 (Rated for Div. 2)补题

慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ? ? //√,×,? 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x>y)\),问能否将\(x-y\)拆成任意多个质数之和 1.任意大于\(1\)的整数\(k\)都可以用\(2\)与\(3\)的线性表示 证: 若\(k\)是偶数,显然: 若\(k\)是奇数,则\(k\)可以表示成\(k = 3 + 2*k'\),显然: 毕. #include<bits/stdc++.h&

Codeforces Round #634 (Div. 3) 补题

A. Candies and Two Sisters 签到题,直接输出即可 代码 #include<bits/stdc++.h> #define INF 0x3f3f3f3f typedef long long ll; using namespace std; inline void read(int &p) { p=0;int flag=1;char c=getchar(); while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();} w

4.30-5.1cf补题

//yy:拒绝转载!!! 悄悄告诉你,做题累了,去打两把斗地主就能恢复了喔~~~ //yy:可是我不会斗地主吖("'▽'") ~~~那就听两遍小苹果嘛~~~ 五一假期除了花时间建模,就抽空把最近没做的CF题补了点..毕竟明天开始又要继续上好多课呐...Yes, I can!(? •_•)?……(I can Huá shuǐ~~) codeforces 803 A. Maximal Binary Matrix   [简单构造] 题意:n行和n列填充零矩阵. 您要将k个1放在其中,使得得到

[2015hdu多校联赛补题]hdu5371 Hotaru&#39;s problem

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5371 题意:把一个数字串A翻过来(abc翻过来为cba)的操作为-A,我们称A-AA这样的串为N-sequence,现在给你一个数字串,问你这个串中最长的N-sequence子串长度 解:可以想到A-A是一个回文串,-AA也是一个回文串,那么首先Manacher跑一遍求出所有回文子串 可以想到任意两个互相覆盖的回文子串都可以表示成N-sequence 然后有三种搞法: 1.时间复杂度O(N*logN

补题 留空

这两道题虽然不是很难,但是目前还不会,在这留个地,省赛之后多刷点这种类型的题,再补上. 1. http://acm.hdu.edu.cn/showproblem.php?pid=3306 矩阵快速幂的题,相加平方和. 2.http://acm.hdu.edu.cn/showproblem.php?pid=3308 线段树 补题 留空,码迷,mamicode.com