容器vector
问题 C: 决战宾果巅峰
时间限制: 1 Sec 内存限制: 128 MB
[提交] [状态]
题目描述
段考结束了!萝班善良的姜姜老师决定进行⼀场游戏——欢乐分数大方送之决战宾果巅峰。
游戏按照如下方式进行:
1. 萝班每位学生先在纸上画好5×5的方格
2. 萝班每位学生在方格中填上1至25的数字,每种数字恰填入⼀次
3. 萝班每位学生将填好数字的纸交给姜姜老师
4. 姜姜老师根据他的心情选择⼀个1至25的排列 P 作为开奖顺序
5. 对于每张纸,依照 P 中的顺序⼀⼀进行标记,直到集满⼀条线为止
6. 每标记⼀个数字,该张纸对应的学生段考分数就加⼀分(欢呼)
在本游戏中⼀张纸共有十二条可能的线:五条横线、五条直线、两条对角线。
由于人工⼀张⼀张进行开奖实在太辛苦了,也容易有错漏之疑虑。因此希望你能写个开奖统计程序帮帮姜姜老师。
输入
第⼀行有⼀个整数 n,代表萝班共有几位学生,依序编号为1,2,...,n。
接下来5n 行,每五行为⼀组,依序代表每位学生纸上所填入的数字。
最后⼀行包含25个数字,代表姜姜选择的开奖顺序 P。
输出
为了方便姜姜老师统计,请对于每个存在的加分分数,输出有哪些学生符合条件。
输出格式为:"score: id id ... id"(不包含引号),其中每个学生编号前恰有⼀个空白,且行尾无空白。请按照加分分数由小到大输出,同样加分分数的学生编号也请由小到大输出。
样例输入 Copy
3
01 02 03 04 05
06 07 08 09 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
01 06 11 16 21
02 07 12 17 22
03 08 13 18 23
04 09 14 19 24
05 10 15 20 25
15 20 19 10 17
01 12 18 23 04
06 08 25 22 16
24 21 07 11 02
14 05 09 03 13
11 14 15 05 08 10 18 22 07 20 21 19 02 25 12 03 13 09 17 24 16 04 01 23 06
样例输出 Copy
14: 1 2
15: 3
提示
【数据规模】
• 1≤ n ≤30
• 为求版面美观,纸上的数字以及开奖顺序均补零至两位数
• 1至25在每位学生纸上以及开奖顺序中均恰出现⼀次
其实此题没有很难做.......但是纪念一下今天vector的使用吧,我的几个数据比较也从三个循环缩减到了1个循环,👍
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>score[30];
int pai[30];
struct node
{
int A[10][10];
int B[10][10];
} st[35];
int main()
{
int n;
scanf("%d",&n);
for(int i=1; i<=n; i++)
{
for(int j=1; j<=5; j++)
{
for(int k=1; k<=5; k++)
scanf("%d",&st[i].A[j][k]);
}
}
for(int i=1; i<=25; i++)
{
int a;
scanf("%d",&a);
pai[a]=i;
}
for(int i=1; i<=n; i++)
{
int minn=25;
for(int j=1; j<=5; j++)
{
for(int k=1; k<=5; k++)
{
st[i].B[j][k]=pai[st[i].A[j][k]];
}
}
int maxnd1=0,maxnd2=0;
for(int j=1; j<=5; j++) //lie
{
int maxnh=0,maxnl=0;
for(int k=1; k<=5; k++)
{
maxnh=max(maxnh,st[i].B[j][k]);
maxnl=max(maxnl,st[i].B[k][j]);
}
maxnd1=max(maxnd1,st[i].B[j][j]);
maxnd2=max(maxnd2,st[i].B[j][6-j]);
minn=min(minn,maxnh);
minn=min(minn,maxnl);
}
minn=min(minn,maxnd1);
minn=min(minn,maxnd2);
score[minn].push_back(i);
}
for(int i=1;i<=25;i++)
{
if(!score[i].empty())
{
printf("%d:",i);
for(int j=0;j<score[i].size();j++)
{
printf(" %d",score[i][j]);
if(j==score[i].size()-1) printf("\n");
}
}
}
return 0;
}