Advertisement
erfanul007

UVa 154

Jan 8th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<vi> vvi;
  8. typedef pair<int,int> pii;
  9. typedef vector< pii > vpii;
  10. typedef set<int> sti;
  11.  
  12. #define pb push_back
  13. #define pob pop_back
  14. #define mp make_pair
  15. #define ff first
  16. #define ss second
  17. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  18. #define loop(i,y) for(int i=0; i<int(y); i++)
  19. #define rloop(i,y) for(int i=int(y)-1; i>=0; i--)
  20. #define read() freopen("input.txt", "r", stdin)
  21. #define write() freopen("output.txt", "w", stdout)
  22. #define cspf(i) printf("Case %d: ", i)
  23. /// Constants
  24. #define eps 1e-9
  25. #define PI acos(-1.0) // 3.1415926535897932
  26.  
  27. int main()
  28. {
  29. read();
  30. while(1){
  31. char ch[110][110];
  32. int i=0;
  33.  
  34. while(1){
  35. i++;
  36. scanf("%[^\n]",ch[i]);
  37. getchar();
  38. if(ch[i][0]=='#')
  39. return 0;
  40. if(ch[i][0]=='e'){
  41. i--;
  42. break;
  43. }
  44. }
  45. int ln=strlen(ch[1]);
  46. int mn=0,x,j,k;
  47. for(j=1;j<=i;j++){
  48. int cnt=0;
  49. for(k=1;k<=i;k++){
  50. int w=0;
  51. while(w<ln){
  52. int n=0;
  53. while(n<ln){
  54. if(ch[j][w]==ch[k][n])
  55. break;
  56. n++;
  57. }
  58. w+=2;
  59. n+=2;
  60. if(ch[j][w]==ch[k][n])
  61. cnt++;
  62. w+=2;
  63. }
  64. }
  65. if(cnt>mn){
  66. mn=cnt;
  67. x=j;
  68. }
  69. }
  70. printf("%d\n",x);
  71. }
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement