CSP-J 2026 游记

· · 生活·游记

本人初二 蒟蒻喵~

before 初赛

上课就练一点J组笔试题,有时30多,有时79.5,还是有一点波动,觉得进初赛有点悬。

初赛

题还是很简单的,但还是擦着分数线过了。

between 初赛 and 复赛

每周在学校编程班写代码,最高一次190。准备拿二等了。os:上了一等请XJY吃饭。

复赛

T1几个if直接过,但其他几个同学经常坐高铁E座。

T2一开始没读懂题,先做的T3喵~

#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5; 
int n,m,cnt;
long long a[N],sum=-1;
bool cmp(long long x,long long y){
    return x>y;
}
int main(){
    std::ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++){
        if(cnt==m) break;
        int x=log(a[i]);
        if(pow(2,x)==a[i]){
            if(sum>=a[i]){
                sum=sum&a[i];
                cnt++;
            } else {
                continue;
            }
        } else {
            if(sum=-1) sum=a[i];
            else sum=sum&a[i];
            cnt++;
        }
    }
    cout<<sum;
    return 0;
}

第18行log函数写错了,最终30pts。 在log加上2变成log2(a[i])能拿60pts。QwQ

回头看T2,还是没看懂,于是看了T4喵 因为没有学过DP,所以用了map和栈去模拟,拿了28pts,我们班最高拿了48pts。

三看T2,终于看懂了喵~

#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5; 
int n,a[N];
char c[N];
long long sum;
int main(){
    std::ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>c[i];
    }
    int l=1,r=n;
    while(l<r){
        if(a[l]>a[r]){
            if(c[l]!=c[r]){
                sum+=a[r];
                a[l]-=a[r];
            }
            r--;
        } else if(a[l]<a[r]){
            if(c[l]!=c[r]){
                sum+=a[l];
                a[r]-=a[l];
            } 
            l++;
        } else {
            if(c[l]!=c[r]){
                sum+=a[l];
            }
            l++;
            r--;
        }
    }
    cout<<sum;
    return 0;
}

但是,第18行和第24行代码位置写错了,只拿了72pts,最令人气愤的是,赛后在洛谷自测中拿了100pts。 QwQ

after 复赛

dream:100pts+100pts+50pts+28pts=278pts=一等
reality:100pts+64pts+30pts+36pts=230pts=二等

max:
100pts+100pts+100pts+36pts=336pts=一等

毕竟还是蒟蒻,不要太为难自己了。

最后,祝看到这篇游记的OIer每天rp++,你们的前途如星星般耀眼璀璨喵~