Skip to content

Instantly share code, notes, and snippets.

@domperor
Created September 24, 2019 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domperor/0ba2e2ec24b2198c56d96521ab59a381 to your computer and use it in GitHub Desktop.
Save domperor/0ba2e2ec24b2198c56d96521ab59a381 to your computer and use it in GitHub Desktop.
AtCoder Beginners Selection 10. ABC 086 C - Traveling solved in plain TeX
\read-1to\n
\newcount\N
\newcount\T
\newcount\D
\N\n
\def\flag{Yes}
\def\readline#1 #2 #3{\def\t{#1}\def\x{#2}\def\y{#3}}
\readline0 0 0
\def\loop{%
\let\tt\t
\let\xx\x
\let\yy\y
\read-1to\I\expandafter\readline\I
\T\t\advance\T-\tt
\ifnum\x>\xx \D\x\advance\D-\xx\else \D\xx\advance\D-\x\fi
\ifnum\y>\yy \advance\D\y\advance\D-\yy\else \advance\D\yy\advance\D-\y\fi
\ifnum\the\D>\the\T\def\flag{No}\fi
\advance\T-\the\D
\D\the\T
\divide\D by2
\multiply\D by2
\ifnum\the\T>\the\D\def\flag{No}\fi
\ifnum\the\N>1\advance\N-1\loop\fi
}
\loop
\immediate\write16{\flag}
\end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment