Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

msnp1381's blog

By msnp1381, 3 years ago, In English

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;

}

~~~~~

  • Vote: I like it
  • 0
  • Vote: I do not like it