跳到正文

个人记录

ABC_329_abc

luoxinyi666约 3 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年6月2日
篇幅
约 3 分钟

版本

  1. v1当前

  • 比赛链接——> AtCoder ABC 329

  • abc a题:

问题陈述:获得一个由大写英文字母组成的字符串,请用空格分隔每一个字符,并按输入顺序依次输出.

  • 思路步骤如下:

1:输入字符串;

2:循环遍历字符串;

3:输出字符串(加空格!).

  • 代码如下:

C++
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int len;
    cin>>s;
    len=s.size()-1;
    for (int i=0;i<len;i++){
       cout<<s[i]<<" ";
    }
    cout<<s[len];
    return 0;
}
  • 注意事项:

唯1的一个:输出时要加空格!

  • abc b题:

  • 问题陈述:

你将得到n个整数,a[1],a[2]……,a[n]。请在这些不为最大的数中找到最大的~~(也就是找到第二大的)

  • 思路步骤如下:

1:输入数组

2:用sort排序

3:去除重复数字

4:输出次大值

  • 代码如下:

C++

#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b){
    return a>b;
}
int main(){
    int a[101],n;
    cin>>n;
    for(int i=0;i<n;i++){
       cin>>a[i];
    	}
    sort(a,a+n,cmp);
    unique(a,a+n);
    cout<<a[1];
    return 0;//结尾(好习惯)
}
  • 注意事项:

    无

- abc c题:

- 问题陈述:

代码
得到一个长度为N的字符串S,由小写英文字母组成,求S中重复字符的非空子串的数量。 (就是各个字符连续出现最多数量的和)

- 温馨提示:

· 这个题有些许复杂,可以先输入字符串,一一搜索,搜索过的至标为‘0’(字符),用变量来统计出现次数,最后输出。(听起来很难的样子)

- 代码如下:

C++
#include<bits/stdc++.h>
using namespace std;
char a[200010],h;
int n,cnt,fc,as;
int main(){
  cin>>n;
  cin>>a;
  for(int i=0;i<n;i++){
     if(a[i]=='0') continue;
         h=a[i];
         cnt=0;
         fc=1;
      for(int j=i;j<n;j++){
          if(a[j]==h){
             a[j]='0';
             cnt++;
          }else {
             if(cnt>=fc)fc=cnt;
               cnt=0;
             }
          }
      if(cnt>=fc){
 	   fc=cnt;
       }as=as+fc;
     }

  cout<<as;
  return 0;
}

·最后总结:

代码
	这一次比赛的题目难度适中,也是第一次
    打比赛,可能不太适应,以后每周坚持打一次,渐渐适应。
原文