#include<iostream> #include<list> #include<string> #include<cstring> #include<sstream> #include<cctype> #include<string.h> #include<algorithm> #include<cmath> #include<stack> #include<fstream> #include<cstdlib> #include<vector> #include<map> #include<set> #include<utility> #include<iomanip> #include<queue> using namespace std; #define INF (1<<63)-1 #define SET(a) memset(a,-1,sizeof(a)) #define ALL(a) a.begin(),a.end() #define CLR(a) memset(a,0,sizeof(a)) #define PB push_back #define FOR(i,n) for(int i = 1;i<=n;i++) #define PI acos(-1.0) #define EPS 1e-9 #define MP(a,b) make_pair(a,b) #define min3(a,b,c) min(a,min(b,c)) #define max3(a,b,c) max(a,max(b,c)) #define READ freopen("input.txt", "r", stdin) #define WRITE freopen("output.txt", "w", stdout) #define LL long long #define MOD 1000000007 #define S(a) scanf("%d",&a) #define P(a) printf("%d",a) #define KS printf("Case %d: ",kk++) #define NL printf("\n") #define MX 1010 int main() { int k,n,tmp,cnt; bool chk; string institute[MX]; while(cin>>k>>n) { if(k==0 && n==0) break; cnt=0; vector<int>v[MX]; set<int>st[MX]; for(int i=1;i<=n;i++) { cin>>institute[i]; for(int j=1;j<=k;j++) { cin>>tmp; v[tmp].PB(i); st[tmp].insert(i); } } for(int i=1;i<=n;i++) { chk=true; if(v[i].size()!=st[i].size()) chk=false; else if(v[i].size()!=k) chk=false; else { for(int j=0;j<v[i].size();j++) if(institute[i]==institute[v[i][j]]) { chk=false; break; } } if(!chk) cnt++; } if(!cnt) cout<<"NO PROBLEMS FOUND"<<endl; else if(cnt==1) cout<<"1 PROBLEM FOUND"<<endl; else cout<<cnt<<" PROBLEMS FOUND"<<endl; } return 0; }
Friday, 21 September 2012
UVa 12394 - Peer Review Solution
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment