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. 日常-acm-排列

    用1-9组成三个数abc,def,ghi,每个数字恰好出现一次,要求abc:def:ghi=1:2:3.按照“abc def ghi”输出所有解,每行一个解. #include <iostrea ...

  2. hdu-1874 畅通工程续---模板题

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1874 题目大意: 求起点到终点的最短距离 解题思路: 注意重边,其他的就是模板 #include&l ...

  3. vuejs组件的重要选项

    new Vue({ el:'#demo', data:{ message:'Hello vue.js!' } }) 我们看到这个括号里面包含了很多中间的选项,小括号里面其实是一些参数,这些参数指定了实 ...

  4. SpringBoot操作MongoDB实现增删改查

    本篇博客主讲如何使用SpringBoot操作MongoDB. SpringBoot操作MongoDB实现增删改查 (1)pom.xml引入依赖 <dependency> <group ...

  5. Angular6中[ngClass]、[ngStyle]的基本使用

    1.ngStyle 基本用法 <div [ngStyle]="{'background-color':'green'}"></<div> 判断添加 & ...

  6. vue动画使用javascript钩子函数

    钩子函数从before-enter – enter –after-enter-entercancelled也是一个完整的生命周期 <transition   v-on:before-enter= ...

  7. WinSCP使用与linux命令(小部分命令)

    一.下载一个WinSCP WinSCP是一个Windows环境下使用SSH的开源图形化SFTP客户端.同时支持SCP协议.它的主要功能就是在本地与远程计算机间安全的复制文件..winscp也可以链接其 ...

  8. 黑马基础阶段测试题:创建一个存储字符串的集合list,向list中添加以下字符串:”C++”、”Java”、” Python”、”大数据与云计算”。遍历集合,将长度小于5的字符串从集合中删除,删除成功后,打印集合中的所有元素

    package com.swift; import java.util.ArrayList; import java.util.List; import java.util.ListIterator; ...

  9. 笔试算法题(46):简介 - 二叉堆 & 二项树 & 二项堆 & 斐波那契堆

    二叉堆(Binary Heap) 二叉堆是完全二叉树(或者近似完全二叉树):其满足堆的特性:父节点的值>=(<=)任何一个子节点的键值,并且每个左子树或者右子树都是一 个二叉堆(最小堆或者 ...

  10. 数据库sql语句的exists和in的区别

    性能变化的关键: #1 执行的先后顺序 谁是驱动表,谁先执行查询,谁后执行查询 #2 执行过程 exists的优点是:只要存在就返回了,这样的话很有可能不需要扫描整个表.   in需要扫描完整个表,并 ...