Files
adamfandClaude Opus 5.5 ac66ad6b03 Tidy the usaco CLI: prefixes everywhere, LOCAL debug builds, git-based dates
- done/skip/undo accept unique prefixes like every other command
- builds define LOCAL (-I repo root): the template includes debugging.h
  and enables DBG/printV only locally, so main.cpp is submittable as-is
- run/build/test --debug (or USACO_DEBUG=1): ASan/UBSan + _GLIBCXX_DEBUG
- list/stats date problems by git history, not mtimes reset by checkouts
- template/tpl is now an alias of reset (which gains -y); fixes template
  dropping the STDIO line
- run shows <io>.out via detect_io instead of the first *.out
- debugging.h: size_t loop indices (no -Wsign-compare noise)
- zsh completion for i/cat/copy; README covers test, io, reset, --debug
- ignore a.out

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 22:39:16 +01:00

92 lines
2.2 KiB
C++

#include <algorithm>
#include <climits>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#ifdef LOCAL
#include "debugging.h"
#endif
using namespace std;
// ----- FILE IO -----
#define STDIN(filename) freopen(filename, "r", stdin)
#define STDOUT(filename) freopen(filename, "w", stdout)
#define NL '\n'
// ----- FOR LOOPS -----
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FD(i,L,R) for (int i = L; i > R; i--)
#define FDE(i,L,R) for (int i = L; i >= R; i--)
// ----- WEZ -----
#define takeI(n) int (n); cin >> n
#define takeII(n,m) int (n),(m); cin >> n >> m
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
#define whileZ takeI(T); while(T--)
//
// ----- MAX MIN -----
#define REMAX(a,b) (a)=max((a),(b))
#define REMIN(a,b) (a)=min((a),(b))
// ----- DEBUG -----
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
// ----- STL DS
#define ALL(c) (c).begin(),(c).end()
int main() {
STDIN("mowing.in");
STDOUT("mowing.out");
map<pair<int,int>, int> seen;
int x = 0, y = 0, t = 0;
seen.insert({{x, y}, t});
int maxRes = INT_MAX;
whileZ {
char dir;
int steps;
cin >> dir >> steps;
switch (dir) {
case 'N':
F(i, 0, steps) {
t++;
y++;
if (seen.count({x,y})) maxRes = min(maxRes, t - seen[{x,y}]);
seen.insert({{x, y}, t});
}
case 'S':
F(i, 0, steps) {
t++;
y--;
if (seen.count({x,y})) maxRes = min(maxRes, t - seen[{x,y}]);
seen.insert({{x, y}, t});
}
case 'E':
F(i, 0, steps) {
t++;
x++;
if (seen.count({x,y})) maxRes = min(maxRes, t - seen[{x,y}]);
seen.insert({{x, y}, t});
}
case 'W':
F(i, 0, steps) {
t++;
x--;
if (seen.count({x,y})) maxRes = min(maxRes, t - seen[{x,y}]);
seen.insert({{x, y}, t});
}
}
}
#ifdef LOCAL
cerr << seen;
#endif
cout << maxRes << NL;
return 0;
}