首页 > 代码库 > hdu 4194(模拟)

hdu 4194(模拟)

符合三者之一的则不满足规定,求不满足规定的个数。直接模拟。

1.被同一个人审查多次

2.被和自己同一组织的审查

3.被审查次数不等于k

代码如下:

 1 /************************************************** 2  * Author     : xiaohao Z 3  * Blog     : http://www.cnblogs.com/shu-xiaohao/ 4  * Last modified : 2014-06-28 17:36 5  * Filename     : hdu_4194.cpp 6  * Description     :  7  * ************************************************/ 8  9 #include <iostream>10 #include <cstdio>11 #include <cstring>12 #include <cstdlib>13 #include <cmath>14 #include <algorithm>15 #include <queue>16 #include <stack>17 #include <vector>18 #include <set>19 #include <map>20 #define MP(a, b) make_pair(a, b)21 #define PB(a) push_back(a)22 23 using namespace std;24 typedef long long ll;25 typedef pair<int, int> pii;26 typedef pair<unsigned int,unsigned int> puu;27 typedef pair<int, double> pid;28 typedef pair<ll, int> pli;29 typedef pair<int, ll> pil;30 31 const int INF = 0x3f3f3f3f;32 const double eps = 1E-6;33 const int LEN = 1001;34 map<string, int> mp;35 int n, k, top;36 int num[LEN];37 vector<int> tab[LEN];38 39 int ch(string s){40     if(!mp.count(s)) mp[s] = top++;41     return mp[s];42 }43 44 int main()45 {46 //    freopen("in.txt", "r", stdin);47 48     char str[1010];49     int tmp;50     while(scanf("%d%d", &k, &n) != EOF){51         if(!k && !n) break;52         for(int i=0; i<LEN; i++) tab[i].clear();53         top = 0; mp.clear();54         for(int i=0; i<n; i++){55             scanf("%s", &str);56             num[i] = ch(str);57             for(int j=0; j<k; j++){58                 scanf("%d", &tmp);59                 tmp --;60                 tab[tmp].PB(i);61             }62         }63         int ans = 0;64         for(int i=0; i<n; i++){65             if(tab[i].size() != k) ans ++;66             else{67                 map<int, int> st;68                 int cc = 0;69                 for(int j=0; j<tab[i].size(); j++){70                     int x = tab[i][j], y = num[i];71                     if(num[x] == y || st.count(x)){72                         ans ++;break;73                     }else st[x] = 1;74                 }75             }76         }77         if(ans == 0) puts("NO PROBLEMS FOUND");78         else if(ans == 1) puts("1 PROBLEM FOUND");79         else printf("%d PROBLEMS FOUND\n", ans);80     }81     return 0;82 }
View Code