|
|
back to boardC++ solution Posted by gleb@il 29 Nov 2019 00:31 #include <iostream> #include <set> using namespace std; int main() { int index = 0, cnt = 0, n; set<string> a, b, c; a.insert("Alice"); a.insert("Ariel"); a.insert("Aurora"); a.insert("Peter"); a.insert("Phil"); a.insert("Olaf"); a.insert("Phoebus"); a.insert("Ralph"); a.insert("Robin"); b.insert("Bambi"); b.insert("Belle"); b.insert("Bolt"); b.insert("Mulan"); b.insert("Mowgli"); b.insert("Mickey"); b.insert("Silver"); b.insert("Simba"); b.insert("Stitch"); c.insert("Dumbo"); c.insert("Genie"); c.insert("Jiminy"); c.insert("Kuzko"); c.insert("Kida"); c.insert("Kenai"); c.insert("Tarzan"); c.insert("Tiana"); c.insert("Winnie"); cin >> n; int a1=0,b1=1,c1=2; for(int i = 0; i < n; i++) { string ask; cin >> ask; if(*a.find(ask) == ask) { cnt += abs(index - a1); index = a1; } if(*b.find(ask) == ask) { cnt += abs(index - b1); index = b1; } if(*c.find(ask) == ask) { cnt += abs(index - c1); index = c1; } } cout << cnt; } |
|
|