跳到正文

生活·游记

CSP - J 邮寄【2025】

lique00约 7 分钟
原文
文章信息与版本

文章信息

发布
2025年9月27日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 7 分钟
获赞
1

版本

  1. v2当前
  2. v1

今年作为糖衣的新高一,参加了csp,高一对于信竞来说已经算是耄耋之年了吧,周五下午第三节课后,就离开了学校,四点多的火车。

今年住的是星程酒店,环境还算不错,和yqs在一个房间,晚上在对面的饭店举行了团建,有lzy,jms说了一些注意事项

回到房间,半夜yqs想上厕所,我们两个目送神州N号升天,一直僵持到了 01::3501::35 左右才睡觉

CSP−JCSP-J

T1T1 拼数拼数

看了三眼,觉得是想出了正解

遍历输入的字符串的每一位,如果是数字就存在一个数组里面,最后将数组从大到小排序后来发现其实只开0-10的桶就行了

五分钟就秒了T1

赛时估分 100100 ptspts

实际成绩 100100 ptspts

C++
//逆流河上万仙退,爱情不敌坚持泪

#include <bits/stdc++.h>
using namespace std;

string s;
int a[1000005];
int tot;

int main()
{
    cin >> s;
    for (int i = 0; i <= s.size() - 1; ++i)
    {
        if (s[i] >= '0' && s[i] <= '9') a[++tot] = s[i] - '0'; 
    }
    sort(a + 1, a + tot + 1);
    for (int i = tot; i >= 1; --i) cout << a[i];
    return 0;
}

T2T2 座位座位

在纸上用数据推了一会,发现不需要开二维数组,只用ii jj 两个下标模拟行列就行了,对于列的奇偶性进行判断,判断ii是加还是减,后来虚空调试了2525分钟,发现只输出了n个数,并且数组是从小到大排的

C++
//逆流河上万仙退,爱情不敌坚持泪

#include <bits/stdc++.h>
using namespace std;

int a[10000005];
int n, m, tot = 1;

int main()
{
    cin >> n >> m;
    
    for (int i = 1; i <= n * m; ++i) cin >> a[i];
    
    int pos = a[1];
    
    sort(a + 1, a + n * m + 1, greater<int>());
    
    int i = 1, j = 1;
    
    if (a[tot] == pos)
    {
        cout << j << ' ' << i << '\n';
        return 0;
    }
    
    while (1)
    {
        if (j % 2 == 1 && i < n) i++;
        else if (j % 2 == 0 && i > 1) i--;
        else if (j % 2 == 1 && i == n) j++;
        else if (j % 2 == 0 && i == 1) j++;
        tot++;
        if (a[tot] == pos)
        {
            cout << j << ' ' << i << '\n';
            break;
        }
    }
    
    return 0;
}

此时已经过了4545分钟左右,感觉这次稳了

赛时估分 100100 ptspts

实际成绩 100100 ptspts

T3T3 异或和异或和

本来用的是前缀和 + DP,但是状态转移方程没推出来,,墨迹了两个小时,此时离考试结束仅不到一个小时,匆匆打了个智障小贪心就走了

C++
//逆流河上万仙退,爱情不敌坚持泪

#include <bits/stdc++.h>
using namespace std;

const int N = 5e5 + 10;
int a[N], n, num, k, pos;

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];

    
    for (int i = 1; i <= n; ++i)
    {
        int l = i, r = l + 1;
        pos = a[l];
        while (r < n)
        {
            if (a[l] == k)
            {
                num++;
                l = r + 1;
                r = l + 1;
                pos = a[l];
                continue;
            }
            else
            {
                if (pos == k)
                {
                    num++;
                    l = r + 1;
                    r = l + 1;
                    pos = a[l];
                }
                else
                {
                    pos = pos ^ a[r];
                    r++;
                }
            }
        }
    }
    if (a[n] == k) num++;
    cout << num << '\n';

    return 0;
}

赛时估分 3030 ptspts

实际成绩 1010 ptspts

T4T4 多边形多边形

看了一眼,没什么思路,看了眼范围,想到了指数级全排列,花了十五分钟打了个暴力

C++
//逆流河上万仙退,爱情不敌坚持泪

#include <bits/stdc++.h>
using namespace std;

string s;
int a[1000005];
int b[1000005];
int n, ans;
int tot;

inline void dfs(int step, int pos)
{
    if (step > pos)
    {
        long long num = 0;
        for (int i = 1; i <= pos; ++i) num += a[b[i]];
        if (num > a[b[pos]] * 2) ans++;
    }
    else
    {
        for (int i = b[step - 1] + 1; i <= n; ++i)
        {
            b[step] = i;
            dfs(step + 1, pos);
        }
    }
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);
    for (int i = 3; i <= n; ++i) dfs(1, i);
    cout << ans << '\n';
    return 0;
}

赛时估分 4040 ptspts

实际成绩 4040 ptspts

赛时估分 100+100+30+40=270100 + 100 + 30 + 40 = 270 ptspts

实际成绩 100+100+10+40=250100 + 100 + 10 + 40 = 250 ptspts

坐标HE,期望能拿1=1=,毕竟是最后一次入门组了

11.16 HE J1=J1= 230

原文