跳到正文

个人记录

总结

sbl_xh约 6 分钟
原文
文章信息与版本

文章信息

发布
2025年8月24日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 6 分钟

版本

  1. v1当前

总结


T1

评测成绩:

unaccpted5̸0tps\color{lightred}{unaccpted}\color{green}{\not50tps}

错误代码:

C++
代码丢失

题意分析:

给定快递重量n和区域m求费用给定快递重量\text{n}和区域\text{m}\\求费用

代码:

C++
#include<bits/stdc++.h>
#define ll long long
using namespace std;
constexpr int N = 1e5+5;
ll n,m;//重量/区域
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n >> m;
    ll k = (n-500)/500;//求多余的重量
    if((n-500)%500!=0) k++;
    if(m==1) cout << 20+k*4;//分区域输出
    else if(m==2) cout << 20+k*6;
    else if(m==3) cout << 20+k*9;
    else if(m==4) cout << 20+k*10;
    else if(m==5) cout << 20+k*17;
	return 0;
}

T2

评测成绩:

WA0̸tps\color{red}{WA\not0}\color{red}{tps}

赛时代码为骗分不展示
题意分析:

给定字符串s,要求在第i时,出布的数量≥出石头的数量最优策略:能出石头就出石头给定字符串\text{s},要求在第i时,出布的数量\ge 出石头的数量\\最优策略:能出石头就出石头

代码:

C++
#include<bits/stdc++.h>
#define ll long long
using namespace std;
constexpr int N = 1e5+5;
string s;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> s;
    int cnt = 0,cnt2 = 0,ans=0;//出石头/出布/答案
    for(int i = 0;i<s.size();i++){//遍历
        if(cnt==cnt2) {//按要求出
             cnt++;
            if(s[i]=='p') ans--;
        }else{
            cnt2++;
            if(s[i]=='g') ans++;
        }
    }
    cout << ans;//输出
	return 0;
}

T3

评测成绩:

WA0̸tps\color{#BB0000}{WA}\color{#BB0000}{\not0tps}

题意分析:

给定3个变量n/r/c,一开始烟在(0,0)处没过一秒烟就会像s[i]的方向移动求:第i+0.5秒时,(r,c)是否有烟给定3个变量\text{n/r/c},一开始烟在(0,0)处\\没过一秒烟就会像s[i]的方向移动\\求:第i+0.5秒时,(r,c)是否有烟

代码:

C++
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n,r,c;
    cin >> n >> r >> c;
    map<pair<int,int>,bool>mp;//烟
    int x=0,y=0;//位置
    mp[{0,0}]=1;//篝火
    string s;//方向
    cin >> s;
    for(int i =0; i<n;i++){
        if(s[i]=='N') x++;//根据题意算方向
        if(s[i]=='S') x--;
        if(s[i]=='W') y++;
        if(s[i]=='E') y--;
        mp[{x,y}]=1;//篝火
        cout << mp.count({r+x,c+y});//输出
    }
    cout << '\n';
    return 0;
}

T4

评测成绩:

unaccpted4̸0tps\color{#FF0F0F}{unaccpted}\color{#0FFF0F}{\not40tps}

题意分析:

给定变量n和n个元素的序列A求∑i=1N−1∑j=i+1Nf(Ai,Aj)定义:f(a,b)=a×10⌊log10(b)⌋+b如:f(1,2)=12f(114,514)=114514给定变量\text{n}和\text{n}个元素的序列\text{A}\\求\sum^{N-1}_{i=1}\sum^{N}_{j=i+1}f(A_i,A_j)\\定义:f(a,b)=a\times10^{\lfloor log_{10}(b)\rfloor}+b\\如:f(1,2)=12\\f(114,514)=114514

代码:

C++
#include<bits/stdc++.h>
#define ll long long
using namespace std;
constexpr int N = 2e5+10,MOD=998244353;
ll a[N],n,ans,s[N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n;//录入
    for(int i = 1;i<=n;i++) {
        cin >> a[i];
        s[i]=(s[i-1]+a[i])%MOD;//前缀和
    }
    for(int i = 1;i<=n;i++){//循环求答案
        ll len = to_string(a[i]).size();//求A[i]的长度
        ans=((ans+s[i-1]*((ll)pow(10,len)%MOD)%MOD)%MOD+(i-1)*a[i]%MOD)%MOD;//求答案
    }
    cout << ans;
    return 0;
}

T5

评测成绩:

AC1̸00tps\color{#00DD00}{AC\not100tps}

题意分析:

给定无符号最大值为232的数n求:把n<<16与n>>16调换给定无符号最大值为2^{32}的数n\\求:把n<<16与n>>16调换

代码:

C++
#include<bits/stdc++.h>
#define ll long long
using namespace std;
constexpr int N = 1e5+5;
unsigned n;//数
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n;
	cout << (n<<16)+(n>>16);//高低位交换
	return 0;
}

原文