Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

Блог пользователя msnp1381

Автор msnp1381, 3 года назад, По-английски

1607E - Robot on the Board 1

acording to tutorial and answer src why u should claulate max-min while you can calulate max <= n(or m) and min >= -n(or -m)

my code: ~~~~~ while (true) { scanf("%c", &c); if (c == 'R'){ r++; x--; } if (c == 'L'){ l++; x++; } if (c == 'U'){ u++; y--;} if (c == 'D'){ d++;y++;} if (c == '\n') break; Mx=max(Mx,x); My=max(My,y); my=min(my,y); mx=min(mx,x); if(Mx>=n||mx<=-n ||My>=m||my<=-m)break;

}

~~~~~

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится