Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //autor: prof. Liviu-Vasile Pinzaru, Palatul Copiilor Suceava & Clubul Copiilor Falticeni
- #include <fstream>
- using namespace std;
- const int dim=10004;
- int w[140];
- int v[dim];
- char ch[dim],s[dim];
- int main()
- {
- ifstream f("maya.in");
- ofstream g("maya.out");
- int p;
- int i=0,j=0,k=0,N=0,x=0,y=0,maxx=0,n;
- int cod, ref1,ref2;
- char a;
- f>>p;
- f>>N;
- if(p==1)
- {
- for(i=1;i<=N;++i)
- {
- f>>a>>x;
- w[a]++;
- }
- for(j='A';j<='Z';++j)
- {
- if(maxx<w[j])
- maxx=w[j];
- }
- //g<<maxx;
- for(j='A';j<='Z';++j)
- {
- if(maxx==w[j])
- g<<(char)j<<' ';
- }
- }
- if(p==2)
- {
- for(i=1;i<=N;++i)
- f>>ch[i]>>v[i];
- ref1='A'-1;
- ref2='Z'+1;
- for(i=1;i<=N;++i)
- {
- f>>n;
- f>>s;
- /***************************/
- ///g<<n<<" "<<s<<'\n';
- /***************************/
- ///x=0;
- y=v[i];
- ///g<<ch[i]<<" "<<v[i]<<'\n';
- cod=ch[i];
- ///-------------------------------
- for(j=0;j<n;++j)
- {
- ///g<<s[j]<<' ';
- if(s[j]=='1')
- ++y;
- else if(s[j]=='2')
- {
- if(cod%2==1)
- ++y;
- ++cod;
- if(cod==ref2)
- cod='A';
- }
- else if(s[j]=='3')
- {
- if(cod%2==0)
- --y;
- ++cod;
- if(cod==ref2)
- cod='A';
- }
- else if(s[j]=='4')
- {
- --y;
- }
- else if(s[j]=='5')
- {
- if(cod%2==0)
- --y;
- --cod;
- if(cod==ref1)
- cod='Z';
- }
- else if(s[j]=='6')
- {
- if(cod%2==1)
- ++y;
- --cod;
- if(cod==ref1)
- cod='Z';
- }
- }
- ///-------------------------------
- g<<char(cod)<<y<<'\n';
- } ///end for(i=1;i<=N;++i)
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement