Advertisement
a53

maya

a53
May 9th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. //autor: prof. Liviu-Vasile Pinzaru, Palatul Copiilor Suceava & Clubul Copiilor Falticeni
  2. #include <fstream>
  3. using namespace std;
  4. const int dim=10004;
  5. int w[140];
  6. int v[dim];
  7. char ch[dim],s[dim];
  8.  
  9. int main()
  10. {
  11. ifstream f("maya.in");
  12. ofstream g("maya.out");
  13. int p;
  14. int i=0,j=0,k=0,N=0,x=0,y=0,maxx=0,n;
  15. int cod, ref1,ref2;
  16. char a;
  17. f>>p;
  18. f>>N;
  19. if(p==1)
  20. {
  21. for(i=1;i<=N;++i)
  22. {
  23. f>>a>>x;
  24. w[a]++;
  25. }
  26.  
  27. for(j='A';j<='Z';++j)
  28. {
  29. if(maxx<w[j])
  30. maxx=w[j];
  31. }
  32. //g<<maxx;
  33. for(j='A';j<='Z';++j)
  34. {
  35. if(maxx==w[j])
  36. g<<(char)j<<' ';
  37. }
  38. }
  39. if(p==2)
  40. {
  41. for(i=1;i<=N;++i)
  42. f>>ch[i]>>v[i];
  43. ref1='A'-1;
  44. ref2='Z'+1;
  45.  
  46. for(i=1;i<=N;++i)
  47. {
  48. f>>n;
  49. f>>s;
  50. /***************************/
  51. ///g<<n<<" "<<s<<'\n';
  52. /***************************/
  53. ///x=0;
  54. y=v[i];
  55. ///g<<ch[i]<<" "<<v[i]<<'\n';
  56. cod=ch[i];
  57. ///-------------------------------
  58. for(j=0;j<n;++j)
  59. {
  60. ///g<<s[j]<<' ';
  61. if(s[j]=='1')
  62. ++y;
  63. else if(s[j]=='2')
  64. {
  65. if(cod%2==1)
  66. ++y;
  67. ++cod;
  68. if(cod==ref2)
  69. cod='A';
  70. }
  71. else if(s[j]=='3')
  72. {
  73. if(cod%2==0)
  74. --y;
  75. ++cod;
  76. if(cod==ref2)
  77. cod='A';
  78. }
  79. else if(s[j]=='4')
  80. {
  81. --y;
  82. }
  83. else if(s[j]=='5')
  84. {
  85. if(cod%2==0)
  86. --y;
  87. --cod;
  88. if(cod==ref1)
  89. cod='Z';
  90. }
  91. else if(s[j]=='6')
  92. {
  93. if(cod%2==1)
  94. ++y;
  95. --cod;
  96. if(cod==ref1)
  97. cod='Z';
  98. }
  99. }
  100. ///-------------------------------
  101. g<<char(cod)<<y<<'\n';
  102. } ///end for(i=1;i<=N;++i)
  103. }
  104. return 0;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement