比赛链接:[第 66 场周赛](竞赛 - AcWing)
先放代码,题解慢慢补
A AcWing 4606. 奇偶判断
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
int main()
{
string str;
cin>>str;
int num=str[str.length()-1]-'0';
printf("%d\n",num%2);
return 0;
}
B AcWing 4607. 字母补全
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
const int N=1e5+5;
char a[N];
int n;
int cnt[26];
int main()
{
// freopen("1.in","r",stdin);
scanf("%s",a);
n=strlen(a);
int pos=-1;
for(int i=0;i+25<n;i++) {
memset(cnt,0,sizeof cnt);
bool flag=true;
for(int j=i;j<=i+25;j++) {
if(a[j]=='?') continue;
else if(cnt[a[j]-'A']) {
flag=false;
break;
}
else cnt[a[j]-'A']++;
}
if(flag) {
pos=i;
break;
}
}
if(pos==-1) return puts("-1")&0;
for(int i=pos;i<=pos+25;i++) {
if(a[i]!='?') continue;
for(int j=0;j<26;j++) {
if(!cnt[j]) {
a[i]='A'+j;
cnt[j]++;
break;
}
}
}
for(int i=0;i<n;i++) {
if(a[i]=='?') a[i]='A';
putchar(a[i]);
}
puts("");
return 0;
}
C AcWing 4608. 整数分组
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
const int N=100+5;
int n,m;
int cnt[N],a[N];
int sum[N];
int main()
{
// freopen("1.in","r",stdin);
cin>>n;
for(int i=1;i<=n;i++) {
cin>>a[i];
m=max(m,a[i]);
cnt[a[i]]++;
}
for(int i=1;i<=m;i++) {
if(cnt[i]==2 || cnt[i]==0) continue;
else if(cnt[i]==1) sum[1]++;
else sum[3]++;
}
if(sum[1]%2==0) {
puts("YES");
int tmp=0;
for(int i=1;i<=n;i++) {
if(cnt[a[i]]==2) putchar('A');
else if(cnt[a[i]]==1) {
tmp++;
if(tmp<=sum[1]/2) putchar('A');
else putchar('B');
}
else putchar('A');
}
}
else if(sum[3]==0) puts("NO");
else {
puts("YES");
int tmp=0;
bool flag=false;
int supernum=0;
for(int i=1;i<=n;i++)
if(cnt[a[i]]>2) {
supernum=a[i];
break;
}
for(int i=1;i<=n;i++) {
if(cnt[a[i]]==2) putchar('A');
else if(cnt[a[i]]==1) {
tmp++;
if(tmp<=sum[1]/2) putchar('A');
else putchar('B');
}
else if(!flag && a[i]==supernum){
flag=true;
putchar('A');
}
else putchar('B');
}
}
return 0;
}
标签:周赛,typedef,str,int,long,66,include,AcWing
From: https://www.cnblogs.com/cjl-world/p/16631948.html