# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1165129 | Agageldi | Robots (APIO13_robots) | C++20 | 0 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 600005
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define SZ(s) (int)s.size()
ll n, w, h, vis[500][500][5], dp[500][500][10], answer = INT_MAX;
pair <int,int> location[10];
char a[500][500];
pair<int,int> f(int i,int j,int direction) {
while(direction == 1 && j < w && a[i][j + 1] != 'x') j++;
while(direction == 2 && j > 1 && a[i][j - 1] != 'x') j--;
while(direction == 3 && i > 1 && a[i - 1][j] != 'x') i--;
while(direction == 4 && i < h && a[i + 1][j] != 'x') i++;
return {i,j};
}
void solve(int i,int j,int direction,int robot,int op) {
if(vis[i][j][direction] == 1 || dp[i][j][robot] < op) return;
dp[i][j][robot] = op;
vis[i][j][direction] = 1;
pair<int,int> j1 = f(i,j,direction);
for(int x = 1; x <= 3; x++) {
solve(j1.ff,j1.ss,((direction+x>4) ? (direction+x)%4 : direction+x), robot, op+1);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |