首页 > ACM题库 > HDU-杭电 > HDU 4194-Peer Review-模拟-[解题报告]HOJ
2015
05-23

HDU 4194-Peer Review-模拟-[解题报告]HOJ

Peer Review

问题描述 :

For scienti c conferences, scientists submit papers presenting their ideas, and then review each other’s papers to make sure only good papers are presented at the conference. Each paper must be reviewed by several scientists, and scientists must not review papers written by people they collaborate with (including themselves), or review the same paper more than once.
You have been asked to write a program to check if your favorite conference is doing things right. Whether a paper is being reviewed too much, too little, or by the wrong people – the organizers must know before it is too late!

输入:

The fi rst line in each test case has two integers, K (1<=K<=5) and N (1<=N<=1000). K is the number of reviews that each paper will receive, while N is the number of papers to be reviewed. The conference only accepts papers with a single author, and authors can only present a single paper at the conference.
Each of the next N lines describes an author and includes the name of the institution to which the author belongs, followed by the list of the K papers he or she has been requested to review. It is assumed that researchers from the same institution collaborate with each other, where as researchers from diff erent institutions don’t. All institution names are shorter than 10 characters, and contain only upper or lowercase letters and no whitespace. Since we have as many papers as authors, papers are identi ed by their author’s index; paper 1 was written by the first author in the list, and paper N was written by the last author.
The end of the test cases is marked with a line containing K = 0 and N = 0. You should generate no output for this line.

输出:

The fi rst line in each test case has two integers, K (1<=K<=5) and N (1<=N<=1000). K is the number of reviews that each paper will receive, while N is the number of papers to be reviewed. The conference only accepts papers with a single author, and authors can only present a single paper at the conference.
Each of the next N lines describes an author and includes the name of the institution to which the author belongs, followed by the list of the K papers he or she has been requested to review. It is assumed that researchers from the same institution collaborate with each other, where as researchers from diff erent institutions don’t. All institution names are shorter than 10 characters, and contain only upper or lowercase letters and no whitespace. Since we have as many papers as authors, papers are identi ed by their author’s index; paper 1 was written by the first author in the list, and paper N was written by the last author.
The end of the test cases is marked with a line containing K = 0 and N = 0. You should generate no output for this line.

样例输入:

2 3
UCM 2 3
UAM 1 3
UPM 1 2
2 3
UCM 2 3
UAM 1 2
UPM 2 2
0 0

样例输出:

NO PROBLEMS FOUND
3 PROBLEMS FOUND

http://acm.hdu.edu.cn/showproblem.php?pid=4194

题目大意:就是一道英文题,题意很纠结。输入一个K和N,K是没人审核的paper数和每个paper必须刚好被K个人审核,N是paper数。

有problem的:1.被1个人审多次。2.被同组织的审。3.被审次数大于K或者小于K。

解题思路:模拟

代码:

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <algorithm>
#define MAXN 1010
#define INF 0x7fffffff
#define eps 1e-10
#define MAX(x,y) ((x)>(y)? (x):(y))
#define MIN(x,y) ((x)<(y)? (x):(y))
#define MEM(a) (memset((a),0,sizeof(a)))
#define FRE freopen("input.txt","r",stdin)
using namespace std;


string name[MAXN];
int num[MAXN],k,n;
vector <int> review[MAXN];
bool ok[MAXN];

int main()
{
    while(scanf("%d%d",&k,&n) && n)
    {
        memset(ok,0,sizeof(ok));
        memset(num,0,sizeof(num));
        for(int i=1;i<=n;i++)
            review[i].clear();
        for(int i=1;i<=n;i++)
        {
            char temp[20];
            scanf("%s",temp);
            name[i]=temp;
            for(int j=0;j<k;j++)
            {
                int tmp;
                scanf("%d",&tmp);
                review[i].push_back(tmp);
            }
        }
        for(int i=1;i<=n;i++)
            sort(review[i].begin(),review[i].end());
        for(int i=1;i<=n;i++)
            for(int j=0;j<k;j++)
            {
                if(j!=0 && (review[i][j]==review[i][j-1])) //重复票判problem
                {
                    ok[review[i][j]]=1;
                    continue;
                }
                if(name[i]==name[review[i][j]]) //同组织判problem
                    ok[review[i][j]]=1;
                else
                    num[review[i][j]]+=1; 
            }
        int ans=0;
        for(int i=1;i<=n;i++)
            if(ok[i]) ans++;
            else
            {
                if(num[i]!=k) ans++; 
            }
        if(ans==0)
            printf("NO PROBLEMS FOUND\n");
        else
            printf("%d PROBLEMS FOUND\n",ans);
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

参考:http://blog.csdn.net/xfeifeix/article/details/7830797