Your grade is in comparison to how others do on the same champion in the same position, alongside a variety of factors.
Building wrong / off-meta isn't going to improve your grade.
What will improve your grade:
- Warding
- Map presence (are you always in the same lane all game, or is your character around the map, are you near kills in other lanes)
- your KDA (obviously)
- your CS
- Your damage dealt to champions, IF you are playing a champion that is capable of dealing damage
- Objectives (Dragons, Barons, Turrets). Bonus if you're the one who last hit the turret, or you are at least nearby when the turret falls
- Kill participation (if you go 12/0/4, but total kills were 70-0, you're probably not getting an S since you were only part of 16 out of 70 kills - your team could have won without you)
Beyond that, it's pretty hard to tell how advanced Riot's system is. Can it evaluate a death due to a mistake vs a death with no choice vs a good death (i.e. you misposition vs enemy team burns multiple flashes and ults to kill you vs you die engaging a good teamfight that leads to a 5 for 1 ace)? Can it evaluate a missed opportunity to kill an enemy? Does it count how often you land your skillshots? Can it evaluate map pressure (i.e. you draw attention split pushing so your allies can take an inhibitor or baron)? We don't know these things, however since they're part of good play I'd imagine doing them will indirectly help other sources of your mastery rank at least (and will thus help you reach that S rank).
You CAN definitely get good ranks with nothing outstanding.
http://matchhistory.na.leagueoflegends.com/en/#match-details/NA1/2127598696/216460380?tab=overview
I got an S+ on Volibear that game. I built tank volibear like everyone does. I even gave up first blood. I didn't CS all too well. We lost the game (and it WAS winnable)! There were plenty of things I didn't do great, and yet I still got an S+. So clearly the system isn't perfect, but it also evaluates lots of good stuff.