关于 CSP-J 2019 初赛试题
  • 板块灌水区
  • 楼主SBO_乐色
  • 当前回复1
  • 已保存回复1
  • 发布时间2020/10/5 20:01
  • 上次更新2023/11/5 11:54:27
查看原帖
关于 CSP-J 2019 初赛试题
210758
SBO_乐色楼主2020/10/5 20:01

https://ti.luogu.com.cn/problemset/1030 的第 20 题中,程序如下:

#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 10000000;
const int maxs = 10000;

int n;
unsigned a[maxn], b[maxn],res[maxn], ord[maxn];
unsigned cnt[maxs + 1];
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) 
        scanf("%d%d", &a[i], &b[i]);
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < maxs; ++i)
        ①; // 利用 cnt 数组统计数量
    for (int i = 0; i < n; ++i) 
        cnt[i + 1] += cnt[i];
    for (int i = 0; i < n; ++i)
        ②; // 记录初步排序结果
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; ++i)
        ③; // 利用 cnt 数组统计数量
    for (int i = 0; i < maxs; ++i)
        cnt[i + 1] += cnt[i];
    for (int i = n - 1; i >= 0; --i)
        ④ // 记录最终排序结果
    for (int i = 0; i < n; i++)
        printf("%d %d", ⑤);

    return 0;
}

空①的循环,应该是 i < n;下一个循环,应该是 i < maxs 吧。至少在 https://wenku.baidu.com/view/ac3f42d6905f804d2b160b4e767f5acfa0c783aa.html 呈示的原试题中是:

但是否所有原试题都是这样不确定,只是洛谷上的的确不太对感觉。

2020/10/5 20:01
加载中...