Roll-call in Woop Woop High

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 188    Accepted Submission(s): 133

Problem Description
The
new principal of Woop Woop High is not satisfied with her pupils
performance.She introduced a new roll-call process to get a daily
measure of the pupils' learning, which proceeds as follows:At the
beginning of the daily roll-call period each pupil is handed a question,
which they must attempt to answer, before proceeding to their classes. A
pupil stops after the question is answered correctly. Each pupil is
allowed up to five attempts to answer the question correctly. Pupils who
answer correctly on the first attempt are marked present. Pupils who
answer correctly after more than one attempt are encouraged to work at
home. Pupils who fail to develop a correct answer within five attempts
are given remedial classes after school. Pupils who do not give any
answer are marked as abscent. Your task is to write a program that reads
the pupils' assessments and generates performance reports for the
principal to proceed with appropriate actions.
 
Input
The
input starts with an integer K (1 <= K <= 100) indicating the
number of classes. Each class starts with an integer N (1 <= N <=
50) indicating the number of pupils in the class. Each of the following N
lines starts with a pupil's name followed by up-to five assessments of
his/her answers. An assessment of 'yes' or 'y' indicates a correct
answer and an assessment of 'n' or 'no' indicates a wrong answer. A
pupil's name consists of a single string with no white spaces.
 
Output
The attendance report for each class consists of five lines.
The first line consists of the sentence: "Roll-call: X", where X indicates the class number starting with the value of one.
The
second line consists of the sentence: ''Present: Y1 out of N'', where
Y1 is the number of pupils who did not submit a wrong answer.
The
third line consists of the sentence: ''Needs to study at home: Y2 out of
N'', where Y2 is the number of pupils who submitted a number of wrong
answers before submitting the correct answer.
The fourth line
consists of the sentence: ''Needs remedial work after school: Y3 out of
N'', where Y3 indicates the number of pupils whose submitted five wrong
answers.
The fifth line consists of the sentence: ''Absent: Y4 out of N'', where Y4 indicates the number of absent pupils.
 
Sample Input
2
5
Doc n y
sneezy n n no yes
princecharming no n no no n
goofy yes
grumpy n y
5
evilemperor n y
princesslia
r2d2 no no y
obeyonecanopy n no y
darthvedar y
 
Sample Output
Roll-call: 1
Present: 1 out of 5
Needs to study at home: 3 out of 5
Needs remedial work after school: 1 out of 5
Absent: 0 out of 5
Roll-call: 2
Present: 1 out of 5
Needs to study at home: 3 out of 5
Needs remedial work after school: 0 out of 5
Absent: 1 out of 5
 
Source
 

//输出的一共5行,第一行略微有点坑,第一行其实就是指的第几组数据,大概就是case的意思

Recommend
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std; struct pp{
char m[];
int flag1;
int cro,wro,sum;
}a[]; int main()
{
int t;
scanf("%d",&t);
int ans1 = ;
while(t--)
{
int n;
scanf("%d",&n);
getchar();
int max1 = ;
for(int i = ;i < n;i++)
{
gets(a[i].m);
int len = strlen(a[i].m);
int flag = -;
int j = ;
a[i].cro = ;
a[i].wro = ;
a[i].sum = ;
for( ;j < len;j++)
{
if(a[i].m[j] == ' ')
break;
}
j++;
for( ;j < len;j++)
{
if(a[i].m[j] == 'y')
{
flag = ;
a[i].cro++;
if(a[i].m[j+] == 'e')
j = j+;
else
j++;
break;
}
else if(a[i].m[j] == 'n')
{
flag = ;
a[i].wro++;
if(a[i].m[j+] == 'o')
j = j+;
else
j++;
break;
}
} a[i].flag1 = flag;
j++;
for( ;j < len;j++)
{
if(a[i].m[j] == 'y')
{
a[i].cro++;
if(a[i].m[j+] == 'e')
j = j+;
else
j++;
}
else if(a[i].m[j] == 'n')
{
a[i].wro++;
if(a[i].m[j+] == 'o')
j = j+;
else
j++;
}
}
a[i].sum = a[i].cro + a[i].wro;
if(max1 < a[i].sum)
max1 = a[i].sum;
} // for(int i = 0;i < n;i++)
// printf("---%s %d %d %d\n",a[i].m,a[i].cro,a[i].wro,a[i].sum); int ans2 = ,ans3 = ,ans4 = ,ans5 = ;
for(int i = ;i < n;i++)
{
if(a[i].wro == && a[i].cro > )
ans2++;
if(a[i].flag1 == && a[i].cro > )
ans3++;
if(a[i].wro >= )
ans4++;
if(a[i].sum == )
ans5++;
}
printf("Roll-call: %d\n",++ans1);
printf("Present: %d out of %d\n",ans2,n);
printf("Needs to study at home: %d out of %d\n",ans3,n);
printf("Needs remedial work after school: %d out of %d\n",ans4,n);
printf("Absent: %d out of %d\n",ans5,n);
}
return ;
}

HDU 4178 模拟的更多相关文章

  1. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  2. hdu 5012 模拟+bfs

    http://acm.hdu.edu.cn/showproblem.php?pid=5012 模拟出骰子四种反转方式,bfs,最多不会走超过6步 #include <cstdio> #in ...

  3. hdu 4669 模拟

    思路: 主要就是模拟这些操作,用链表果断超时.改用堆栈模拟就过了 #include<map> #include<set> #include<stack> #incl ...

  4. 2013杭州网络赛C题HDU 4640(模拟)

    The Donkey of Gui Zhou Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  5. HDU/5499/模拟

    题目链接 模拟题,直接看代码. £:分数的计算方法,要用double; #include <set> #include <map> #include <cmath> ...

  6. hdu 5003 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=5003 记得排序后输出 #include <cstdio> #include <cstring& ...

  7. hdu 5033 模拟+单调优化

    http://acm.hdu.edu.cn/showproblem.php?pid=5033 平面上有n个建筑,每个建筑由(xi,hi)表示,m组询问在某一个点能看到天空的视角范围大小. 维护一个凸包 ...

  8. HDU 2860 (模拟+并查集)

    Regroup Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  9. hdu 5083(模拟)

    Instruction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

随机推荐

  1. 【HHHOJ】NOIP2018 模拟赛(二十四) 解题报告

    点此进入比赛 得分: \(100+60+100\)(挺好的,涨了一波\(Rating\)) 排名: \(Rank\ 1\) \(Rating\):\(+115\) \(T1\):[HHHOJ13]金( ...

  2. python3安装pip

    wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c ...

  3. shell脚本,awk结合正则来打印文件里面的内容。

    文件内容如下:key1abc d key2 1.想得到如下结果: abc d 2.想得到如下结果: key1key2

  4. swl字符串

    创建字符串方法 去掉时间戳 #define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT ...

  5. C++ 限定名称查找

    限定名称查找规则实际归纳下来很简单,先对::左边的名称进行查找(遵循,限定,无限定),然后在左边查找到的(此时只查找类型名称)名字的作用域内(含内联名称空间件)查找右边出现的名字,查找到即存在(故可以 ...

  6. hello spring boot neo4j

    新建springboot 项目: https://www.cnblogs.com/lcplcpjava/p/7406253.html bug fixs: 1. Maven Configuration ...

  7. 【前端_js】前端跨网络异步获取资源——fetch()

    Fetch API 提供了一个 JavaScript接口,用于访问和操纵HTTP管道的部分,例如请求和响应.它还提供了一个全局 fetch()方法,该方法提供了一种简单,合理的方式来跨网络异步获取资源 ...

  8. hibernate系列之二

    首先先介绍一下持久化: 持久化:将程序数据在持久状态和瞬时状态间转换的机制:即将内存的数据永久存在关系型数据库中: 持久化类的编写规则: 持久化类需要提供无参构造方法: 持久化类的属性需要私有,对私有 ...

  9. docker安装后无法启动问题

    问题报错: Error starting daemon: Error initializing network controller: list bridge addresses failed: no ...

  10. Android中级教程之Android应用程序的生命周期

    Android应用程序的生命周期图 在大部分情况下,每个Android应用都将运行在自己的Linux进程中.当这个应用的某些代码需要执行时,进程就会被创建,并且将保持运行,直到该进程不再需要,而系统需 ...