I believe your performance over a number of statistics including CS, kills, deaths, assists, time dead, damage dealt, damage taken, damage to champions dealt, towers taken, inhibs taken, etc are compared to the average of all the people playing that champion. If your performance is an outlier, you will get a very high or very low grade (depending on if you completely sucked or if you did really really well).
So basically, if the average Annie player only gets 3 kills every game and you get 20, you should be well on your way to earning an S. (A horrible example but just go with it).