|
|
вернуться в форумHERE IS THE ANSWER #include <stdio.h> #include <math.h> #include <iostream> #include <string> using namespace std; int main(){ int n, l = 0; string s[10], t[10], r[10]; scanf("%d", &n); s[0] = "Alice"; s[1] = "Ariel"; s[2] = "Aurora"; s[3] = "Phil"; s[4] = "Peter"; s[5] = "Olaf"; s[6] = "Phoebus"; s[7] = "Ralph"; s[8] = "Robin"; t[0] = "Bambi"; t[1] = "Belle"; t[2] = "Bolt"; t[3] = "Mulan"; t[4] = "Mowgli"; t[5] = "Mickey"; t[6] = "Silver"; t[7] = "Simba"; t[8] = "Stitch"; r[0] = "Dumbo"; r[1] = "Genie"; r[2] = "Jiminy"; r[3] = "Kuzko"; r[4] = "Kida"; r[5] = "Kenai"; r[6] = "Tarzan"; r[7] = "Tiana"; r[8] = "Winnie"; string q[10010]; for(int i = 0; i <= n; i ++){ getline(cin, q[i]); } __int64 k[10010], len = 1, sum = 0; for(int i = 2; i <= n; i ++){ int kk = 0; for(int j = 0; j < 9 ; j ++){ if(q[i] == s[j]){ kk = 1; } if(q[i] == t[j]){ kk = 2; } if(q[i] == r[j]){ kk = 3; } } k[len] = kk; len ++; } k [0] = 1; for(int i = 1; i < len; i ++){ sum += fabs(k[i] - k[i + 1]); } cout << sum << endl; } |
|
|