Current work

This commit is contained in:
2026-08-03 19:03:58 +01:00
parent b48299efb7
commit a79ff12290
46 changed files with 1345 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
#include <algorithm>
#include <climits>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include "../../debugging.h"
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});
}
}
}
cerr << seen ;
cout << maxRes << NL;
return 0;
}