题目:著名出题人小Q每次比赛后都会写一份《赛题分析》,包含比赛概况、每题的参考算法以及一些统计数值。
于一道题来说,小Q会统计最短的验题人代码长度(Shortest judge solution)以及赛内参赛队伍最短的AC代码长度(Shortest team solution)。
统计验题人代码长度比较容易,因为验题人最多也不会超过2020个。但是统计选手代码长度就不容易了,因为大赛区动辄三四百支队伍。
请写一个程序,帮助小Q统计最短代码长度。
分析:就将数字排序后,按照说明输出,注意输出有些空格。
`
#include<iostream>
using namespace std;
int main()
{
int t, n, m,i,j,k;
cin >> t;
for (k = 1; k <= t; k++)
{
cin >> n >> m;
int a[70000], b[70000];
for (i = 0; i < n; i++)
cin >> a[i];
for (i = 0; i < m; i++)
cin >> b[i];
for (i = 0; i < n - 1; i++)
{
for (j = 1; j < n; j++)
{
int s = i;
if (a[s] > a[j])
{
int t;
t = a[s];
a[s] =a[j];
a[j] = t;
}
}
}
for (i = 0; i < m - 1; i++)
{
for (j = 1; j < m; j++)
{
int s = i;
if (b[s] > b[j])
{
int t;
t = b[s];
b[s] = b[j];
b[j] = t;
}
}
}
cout << "Problem " << k + 1000 <<":"<< endl;
cout << "Shortest judge solution: " << a[0] << " bytes." << endl;
if (m == 0) cout << "Shortest team solution: N/A bytes." << endl;
if (m != 0)cout << "Shortest team solution: " << b[0] << " bytes." << endl;
}
}
```