1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
#include <iostream> #include <map> #include <cstdlib> using namespace std; int target[1001]; int target_org[10]; int guess[1001]; int guess_org[10]; map<int,int> mp; int main() { int n,cnt; int match,w_match; int c=1,Ln; while(cin>>n) { if(n==0) break; int i=0; for(int i=1;i<=9;i++) target_org[i]=0; cnt=0; for(int i=1;i<=n;i++) { cin>>target[i]; if(target_org[target[i]]==0) { cnt++; } target_org[target[i]]++; } Ln=1; while(1) { int sum=0; match=0; for(int i=1;i<=9;i++) guess_org[i]=0; mp.clear(); for(int i=1;i<=n;i++) { cin>>guess[i]; sum+=guess[i]; guess_org[guess[i]]++; if(guess[i]==target[i]) { match++; //guess_org[guess[i]]-=1; mp[guess[i]]++; } } if(sum==0) break; w_match=0; for(int i=1;i<=9;i++) { //if(target_org[i]>0 && guess_org[i]>0) //w_match++; if( mp[i]!=0) { if((guess_org[i]-mp[i])>0 && (target_org[i]-mp[i])>0) { if((guess_org[i]-mp[i])<=(target_org[i]-mp[i])) w_match+=(guess_org[i]-mp[i]); else w_match+=(target_org[i]-mp[i]); } } else if(guess_org[i]>0&& target_org[i]>0) { if(guess_org[i]<=target_org[i]) w_match+=guess_org[i]; else w_match+=target_org[i]; } } if(Ln) { cout<<"Game "<<c++<<":\n"; Ln=0; } cout<<" ("<<match<<","<<w_match<<")\n"; } } return 0; } |