Advertisement
Farjana_akter

Untitled

Nov 21st, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. char arr[105][10]= {0};
  4. int cntarr[105][10]= {0};
  5.  
  6.  
  7. int main()
  8. {
  9. string s;
  10. int city=0,i,j,cnt=0,k,ans,mx;
  11. while(cin>>s)
  12. {
  13. if(s[0]=='#')
  14. break;
  15. else if(s[0]=='e')
  16. {
  17. memset(cntarr,0,sizeof(cntarr));
  18.  
  19. ans=0;
  20. mx=0;
  21. for(i=0; i<city; i++)
  22. {
  23. for(j=0; j<5; j++)
  24. {
  25. for(k=0; k<city; k++)
  26. {
  27. if(arr[i][j]==arr[k][j])
  28. cntarr[i][j]++;
  29. }
  30. }
  31. }
  32.  
  33. for(i=0;i<city;i++)
  34. {
  35. for(j=0;j<5;j++)
  36. {
  37. cnt+=cntarr[i][j];
  38. }
  39. if(cnt>mx)
  40. {
  41. mx=cnt;
  42. ans=i+1;
  43. }
  44. cnt=0;
  45. }
  46. cout<<ans<<endl;
  47. city=0;
  48. }
  49. else
  50. {
  51. int len=s.length();
  52. for(i=0; i<len; i++)
  53. {
  54. if(s[i]=='r')
  55. arr[city][0]=s[i+2];
  56. else if(s[i]=='o')
  57. arr[city][1]=s[i+2];
  58. else if(s[i]=='y')
  59. arr[city][2]=s[i+2];
  60. else if(s[i]=='g')
  61. arr[city][3]=s[i+2];
  62. else if(s[i]=='b')
  63. arr[city][4]=s[i+2];
  64. }
  65. city++;
  66. }
  67. }
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement