ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1197. Lonesome Knight

WA #1 please help!
Posted by Freddy 30 May 2013 19:45
I don't understand where I'm wrong. I tried the sample and the result is right!
#include<iostream>
#include<map>
using namespace std;
int main()
{
    int n,num;
    map<char,int> val;
    val['a']=1;val['b']=2;val['c']=3;val['d']=3;val['e']=3;val['f']=3;val['g']=2;val['h']=1;
    val['1']=1;val['2']=2;val['3']=3;val['4']=3;val['5']=3;val['6']=3;val['7']=2;val['8']=1;
    char xy[1];
    cin>>n;
    while(n--)
    {
        cin>>xy;
        num=val[xy[0]]+val[xy[1]];
        if(num==6)
            num+=2;
        if(num==5)
            num++;
        cout <<num<<endl;
    }
}