Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- typedef long long ll;
- class Task
- {
- public:
- void solve(istream& in,ostream& out)
- {
- string s;
- cin >>s;
- ll n=s.length();
- char seat=s[n-1];
- ll a=atol(s.substr(0,n-1).c_str());
- ll res;
- if (a%4==1)
- {
- ll x=a-1;
- res=(x/4)*12+x+(index(seat));
- }
- else if (a%4==2)
- {
- ll x=a-2;
- res=(x/4)*12+x+(index(seat));
- res+=7;
- }
- else if (a%4==3)
- {
- a=a-2;
- ll x=a-1;
- res=(x/4)*12+x+(index(seat));
- }
- else if (a%4==0)
- {
- a-=2;
- ll x=a-2;
- res=(x/4)*12+x+(index(seat));
- res+=7;
- }
- cout <<res<<endl;
- }
- ll index(char a)
- {
- if (a=='f')
- {
- return 1;
- }
- else if (a=='e')
- {
- return 2;
- }
- else if (a=='d')
- {
- return 3;
- }
- else if (a=='a')
- {
- return 4;
- }
- else if (a=='b')
- {
- return 5;
- }
- else
- {
- return 6;
- }
- }
- };
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- istream& in(cin);
- ostream& out(cout);
- Task solver;
- solver.solve(in,out);
- return 0;
- }
Add Comment
Please, Sign In to add comment