Advertisement
MiinaMagdy

11507 - Bender B. Rodríguez Problem

Sep 3rd, 2022
1,010
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6. #define endl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(), x.end()
  9.  
  10. int main() {
  11.     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  12.     int L;
  13.     while (scanf("%d\n", &L), L) {
  14.         char dir, sign;
  15.         char last_sign = '+', last_dir = 'x';
  16.         for (int i = 1; i < L; i++) {
  17.             scanf("%c%c%*c", &sign, &dir);
  18.             if (sign == 'N') continue;
  19.             if (last_dir == 'x') {
  20.                 last_dir = dir;
  21.                 char tmp = (last_sign == '+' ? '-' : '+');
  22.                 last_sign = (sign == '-' ? tmp : last_sign);
  23.             }
  24.             else {
  25.                 if (dir == last_dir) {
  26.                     last_sign = (last_sign == sign ? '-' : '+');
  27.                     last_dir = 'x';
  28.                 }
  29.             }
  30.             //printf("%c%c\n", last_sign, last_dir);
  31.         }
  32.         printf("%c%c\n", last_sign, last_dir);
  33.     }
  34. }
  35.  
Tags: UVA CP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement