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. java Vamei快速教程02 方法和数据成员

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 在Java基础01 从HelloWorld到面向对象,我们初步了解了对象(obje ...

  2. Python开发第四篇

    文件操作 一.文件基本操作 打开文件方法:open f = open("test",encoding="") r:只读模式(只能读取文件,不能做写操作,文件不存 ...

  3. Javascript 向量

    向量 既有大小又有方向的量叫做向量(亦称矢量),与标量相对,用JS实现代码如下,直接搬miloyip的了 Vector2 = function(x, y) { this.x = x; this.y = ...

  4. POJ 3046 Ant Counting(递推,和号优化)

    计数类的问题,要求不重复,把每种物品单独考虑. 将和号递推可以把转移优化O(1). f[i = 第i种物品][j = 总数量为j] = 方案数 f[i][j] = sigma{f[i-1][j-k], ...

  5. IPython安装过程 @win7 64bit

    http://www.360doc.com/content/14/0902/11/16740871_406476389.shtml 为了测验测验一下IPython的应用,今天折腾了好久的从安装包msi ...

  6. Linux yum安装

    一.安装Apache软件步骤:1.安装 yum install httpd 2.启动,关闭 重启等命令systemctl start httpd.service(启动)systemctl restar ...

  7. oc字典放入到数组里,根据字典里的属性排序(重点)

    #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { ...

  8. 常用的ES6语法

    1. let.const 和 block 作用域 let 允许创建块级作用域,ES6 推荐在函数中使用 let 定义变量,而非 var: var a = 2; { let a = 3; console ...

  9. 实用小工具不定期合集(textarea 高度自适应、自动计算Y轴刻度、json转table)

    1.textarea高度自适应 这个非常有用,但是网上的解决方案都不尽人意,话不多说,上代码. function auto (elem) { var minHeight = 30 var change ...

  10. 算法竞赛入门经典5.1 从c到c++

    这个章节主要是讲述了一些c++的特性,在这里面,对我用处最大的应该就是字符串吧.首先是getline,getchar,stringstream的使用了吧. 首先介绍这三个函数. 1. getline函 ...