#323. CSP2019PJ-20
CSP2019PJ-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 < n; ++i)
_________________________; // 利用 cnt 数组统计数量
for(int i = 0; i < maxs; ++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\n", _________________________);
return 0;
}
① 处应填( )。
{{ select(1) }}
- ++cnt[i]
- ++cnt[b[i]]
- ++cnt[a[i] * maxs + b[i]]
- ++cnt[a[i]]
② 处应填( )。
{{ select(2) }}
- ord[--cnt[a[i]]] = i
- ord[--cnt[b[i]]] = a[i]
- ord[--cnt[a[i]]] = b[i]
- ord[--cnt[b[i]]] = i
③ 处应填( )。
{{ select(3) }}
- ++cnt[b[i]]
- ++cnt[a[i] * maxs + b[i]]
- ++cnt[a[i]]
- ++cnt[i]
④ 处应填( )。
{{ select(4) }}
- res[--cnt[a[ord[i]]]] = ord[i]
- res[--cnt[b[ord[i]]]] = ord[i]
- res[--cnt[b[i]]] = ord[i]
- res[--cnt[a[i]]] = ord[i]
⑤ 处应填( )。
{{ select(5) }}
- a[i], b[i]
- a[res[i]], b[res[i]]
- a[ord[res[i]]], b[ord[res[i]]]
- a[res[ord[i]]], b[res[ord[i]]]
相关
在下列比赛中: