prompt
string
response
string
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import itertools n,m=map(int,raw_input().split()) arr=[] for i in range(n): k=list(raw_input()) arr.append(k) start=0 end=0 for i in range(n): for j in range(m): if arr[i][j]=='S': start=[i,j] elif arr[i][j]=='E': end=[i,j] given=map(int,raw_input()) combs=[] dict={0:...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.Scanner; public class TaskB { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(), m = sc.nextInt(); sc.nextLine(); String[] maze = new String[n]; int sx = 0, sy = 0; for(int i = 0; i < n; i++) { maze[i] = sc.nextLine(); int j; if((j...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
n, m = map(int, input().split()) a = [0] * n for i in range(n): a[i] = input() for j in range(m): if a[i][j] == 'S': x1, y1 = i, j s = input() dirr = ['0123', '0132', '0213', '0231', '0312', '0321', '1023', '1032', '1203', '1230', '1302', '1320', '2103', '2130', '2013', '2031', '2310', '2301...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
n, m = map(int, raw_input().split()) mp = [None] * n for i in range(n): mp[i] = list(raw_input()) path = map(int, list(raw_input())) for i in range(n): for j in range(m): if mp[i][j] == 'S': start = (i, j) elif mp[i][j] == 'E': end = (i, j) S4 = [(0, 1, 2, 3), (0, 1, 3...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import itertools n, m = [int(x) for x in raw_input().split()] lst = [] start = None for i in xrange(n): string = raw_input() for j in xrange(m): if string[j] == 'S': start = (i, j) lst.append(string) ways = raw_input() directions = [(1, 0), (0, 1), (-1, 0), (0, -1)] res = 0 for p in i...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
class MyList(list): def __getitem__(self, index): if index < 0: raise IndexError("IOR") return super(MyList, self).__getitem__(index) def set_ptree(per, options): if len(options)<0: return for o in xrange(len(options)): o_copy=list(options) del o_copy[o...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; char g[69][69]; int n, m; string ui; int starti = -1, startj = -1, endi = -1, endj = -1; void pre() { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (g[i][j] == 'S') { starti = i; startj = j; } if (g[i][j] == 'E') { ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
from itertools import permutations n, m = map(int, input().split()) p = [[-1] * m + [0] for i in range(n)] + [[0] * m] for i in range(n): for j, q in enumerate(input()): if q == '#': p[i][j] = 0 elif q == 'S': a, b = i, j elif q == 'E': p[i][j] = 1 s = li...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
from itertools import permutations y,x =map(int, input().split()) M=["" for i in range(y)] for i in range(y): M[i]=input() path=input() for i in range(y): for j in range(x): if M[i][j]=="S": starty=i startx=j mappings=permutations("0123") direction_x=[0,1,0,-1] direction_y=[1,0...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.ArrayList; import java.util.Scanner; public class buggybot { public static ArrayList<String> per = new ArrayList<>(); public static void generate (String s[], String st){ if(st.length()==4) { per.add(st); return; } for (int i = 0; i < 4; i++) { ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, A, B, a, b, k, l, t, flag, cnt = 0; string str[55]; string in; cin >> n >> m; for (i = 0; i < n; ++i) { cin >> str[i]; for (j = 0; j < str[i].length(); ++j) { if (str[i][j] == 'S') { A = i; B = j; } ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; ifstream fi("908B.INP"); char c[55][55]; int n, m, a[5] = {0, 1, 2, 3}, x, y, res; struct data { int x, y; } S, E; string s; int main() { cin >> n >> m; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { cin >> c[i][j]; if (c[i][j] == 'E') { ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
/* ЗАПУСКАЕМ ВЫСОКОГО ░ГУСЯ░▄▀▀▀▄░РАБОТЯГИ░░ ▄███▀░◐░░░▌░░░░░░░ ░░░░▌░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, ans = 0; string s; pair<int, int> start, end; cin >> n >> m; char a[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; if (a[i][j] == 'S') { start.first = i; start.second = j;...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
def check(lab, start, end, steps, d): cur_i, cur_j = start for s in steps: cur_i += d[s][0] cur_j += d[s][1] if cur_i < 0 or cur_i >= len(lab) or cur_j < 0 or cur_j >= len(lab[0]): return False if lab[cur_i][cur_j]: return False if cur_i == end[0] ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.*; import java.util.*; public class BB { public static void main(String[] args)throws Throwable { MyScanner sc=new MyScanner(); PrintWriter pw=new PrintWriter(System.out); int n=sc.nextInt(); int m=sc.nextInt(); char [][] a=new char [n][m]; int sx=0,sy=0; for(int i=0;i<n;i++){ a[i]=s...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.*; import java.io.*; import java.lang.Math.*; public class MainA { static int mod = (int) 1e9 + 7; static int prime[]=new int[100000+1]; static int count=0,n,m; public static void main(String[] args) throws java.lang.Exception { InputReader in = new InputReader(System.in); PrintWriter out=...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
from itertools import permutations def solve_path(path3): for x in range(0, len(path3), +1): if path3 == 'L': x_t -= 1 if Matrix[x_t][y_t] == 'E': wyn += 1 x_p = -1 y_p = -1 x_k = -1 y_k = -1 x_t = -1 y_t = -1 wyn = 0 n,m = map(int, raw_input('').split(' ')) Matrix ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
from itertools import permutations n = 0 m = 0 grid = [] path = '' ct = 0 direc = [] bas = [0, 1, 2, 3] s_x = 0 s_y = 0 e_x = 0 e_y = 0 dx = [0, 0, 1, -1] dy = [1, -1, 0, 0] def io(): global n, m, grid, path n, m = map(int, input().split(' ')) for i in range(0, n, 1): grid.append(input()) path...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
n, m = map(int, input().split()); A = []; for q in range(n): a = input(); B = []; for w in range(m): if a[w] == "S": x0 = w; y0 = q; B.append(a[w]) A.append(B); B = [0, 1, 2, 3]; count = 0; s = input(); #print(x0, y0); for q in range(4): for w in range(4): ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; const int N = 109; int n, m; int a[4] = {0, 1, 2, 3}; int dx[] = {0, 0, -1, 1}; int dy[] = {-1, 1, 0, 0}; char s[N], arr[N][N]; bool in(int i, int j) { return 0 <= i && i < n && 0 <= j && j < m && arr[i][j] != '#'; } int main() { scanf("%d %d", &n, &m); for (int i = 0...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; char ar[55][55]; int m, n; string s; bool visited[60][60]; vector<pair<int, int> > vec; int BFS(int i, int j) { memset(visited, false, sizeof(visited)); queue<pair<int, int> > q; q.push({i, j}); visited[i][j] = true; int cnt = 0; while (!q.empty()) { pair<in...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int n, m; int xs, ys, xe, ye; string s[55]; string way; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> s[i], s[i] = '0' + s[i] + '0'; cin >> way; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (s[i][j] == 'S') xs = i, ys ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
from itertools import permutations n,m=map(int,input().split()) lab="#"*(m+2) for n in range(n): lab+="#"+input()+"#" lab+="#"*(m+2) s=input() cmd=[ord(x)-48 for x in s] pers=permutations([1,-1,m+2,-m-2]) ans=0 for per in pers: where=lab.find("S") for c in cmd: where+=per[c] ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; const int N = 1000; const int dx[4] = {1, -1, 0, 0}; const int dy[4] = {0, 0, -1, 1}; int n, m, res; char a[N][N]; char command[N]; bool inside(int x, int y) { return (0 < x && x <= n && 0 < y && y <= m && a[x][y] != '#'); } int main() { ios_base::sync_with_stdio(false)...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; const long long int mx = 1e6 + 1, Mod = 1e9 + 7; int n, m; string s[55], t; int dmp[25][4], mi = 0; pair<int, int> f(pair<int, int> d, char c, int w) { c -= '0'; if (c == dmp[w][0]) return make_pair(d.first + 1, d.second); if (c == dmp[w][1]) return make_pair(d.first,...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.*; public class Solution { static int n=0; static int m=0; public static void main(String [] args) { Scanner sc=new Scanner(System.in); int ans=0; n=sc.nextInt(); m=sc.nextInt(); String [] arr=new String [n]; for(int i=0;i<n;i++) ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int n, m; int change[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; char square[55][55] = {0}; int step[105] = {0}, t = 0; int ex, ey, sx, sy, ans = 0; void check(int x, int y, int z, int w) { int r = sx, c = sy, a[4] = {x, y, z, w}; for (int i = 0; i < t; i++) { r += ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
def judge(): x, y = stx, sty for ch in s: u = ord(ch) - ord('0') x += loca[u][0] y += loca[u][1] if x < 0 or x >= n or y < 0 or y >= m or tu[x][y] == '#': return False if tu[x][y] == 'E': return True return False R = lambda : map(int, input()....
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
n, m = map(int, input().split()) g = [input() for i in range(n)] s, e = (0, 0), (n-1, m-1) d = list(map(int, list(input()))) for i in range(n): for j in range(m): if g[i][j]=='S': s = (i, j) if g[i][j]=='E': e = (i, j) t = 0 for d2 in range(4): for d3 in range(4): for d4 in range(4): ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e4 + 5; const int mod = 1e9 + 7; int n, m, startx, starty, endx, endy; string s; char ch[55][55]; map<char, char> mp; bool valid(int i, int j) { if (i < 0 || j < 0 || i >= n || j >= m || ch[i][j] == '#') return 0; return 1; } bool chk(string t) { int...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; string field[51]; int main() { std::ios::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; int sx, sy, ex, ey, cx, cy; for (int i = 0, _i = (n); i < _i; ++i) { cin >> field[i]; for (int j = 0, _j = (m); j < _j; ++j) { if (field[i][j] ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.Optional; import java.util.Scanner; public class Main { public static void main(String[] args) { Main main = new Main(); main.solveB(); } private void solveA() { Scanner sc = new Scanner(System.in); String str = sc.next(); long answer = str.chars().filter( asc -> asc == 'a' || a...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.Scanner; public class Directions { static int count, up, down, left, right, startx = 0, starty = 0, endx = 0, endy = 0; static String s = ""; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextIn...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
def move(s, mapp, S, E, d, n, m): A = S[:] for i in s: if A[0] >= n or A[0] < 0 or A[1] < 0 or A[1] >= m: return False if A == E: return True if d[A[0]][A[1]] == '#': return False if mapp[i] == 'l': A[1] -= 1 elif mapp[i] ==...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import itertools num_rows, num_cols = map(int, raw_input().split()) board = [] for i in range(num_rows): board.append(raw_input()) init_position = None for i in range(num_rows): for j in range(num_cols): if board[i][j] == "S": init_position = (i, j) break if init_position ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int f; int n, m; int s1, s2, f1, f2; int ii, jj; char sss[200][200]; void bf(int s) { if (s == 0) { ii++; if (ii > n) { f = 0; return; } } if (s == 1) { ii--; if (ii <= 0) { f = 0; return; } } if (s == 2) { jj++;...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int n, m; char g[53][53]; int d[4]; const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; string s; int stx, sty; bool instruction() { int cx = stx, cy = sty; for (int i = 0; i < s.size(); i++) { cx += dx[d[s[i] - '0']]; cy += dy[d[s[i] - '0']]; if...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class cf908b { // 27 29 // 29 30 // 30 41 // 41 52 public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new S...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class nyb { static int strtI; static int strtJ; static int endI; static int endJ; static String seq; static char [][] maze; static char []D= {'u','d','l','r'}; static int cnt; ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int n, m, a, b, len; char s[105], nm[55][55], x[4] = {'0', '1', '2', '3'}; bool isE(char* X) { int newi = a, newj = b; for (int i = 0; i < len; i++) { if (s[i] == X[0]) { newi -= 1; } if (s[i] == X[1]) { newi += 1; } if (s[i] == X[2]) { ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
from itertools import permutations def check(cmd): global c, field, pos x, y = pos[0], pos[1] for cm in c: if cmd[0] == cm: x += 1 elif cmd[1] == cm: x -= 1 elif cmd[2] == cm: y -= 1 else: y += 1 if x < 0 or y < 0 or x...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
# 0 - вверх, 1 - вправо, 2 - вниз, 3 - влево def goField(field, rule, dirs, start): pos = start # while field[pos[0]][pos[1]] != "E": for i in rule: i = int(i) if dirs[i] == 0: pos[0] -= 1 if dirs[i] == 1: pos[1] += 1 if dirs[i] == 2: pos...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
n,m=[int(i) for i in raw_input().split()] l='' from itertools import permutations from collections import defaultdict for i in range(n): l+=raw_input() dire=raw_input() co=0 for h in permutations('udlr'): fg=l.index('S') d=defaultdict(str) for g in range(4): d[g]=h[g] #print d for i in d...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; char s[55][55]; int s1[110], ss[110], cishu[5]; bool flag[5]; int n, m, len, cnt, num; int ex, ey, sx, sy; int gox[5] = {1, -1, 0, 0}; int goy[5] = {0, 0, 1, -1}; void dfs(int x, int y, int sum) { if (x == ex && y == ey) { cnt++; return; } if (sum >= len) retu...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int n, m, d[1001], t, posis, posjs, posie, posje, j, asd, i, ans; string ss, res, s; bool was[10001]; char a[101][101]; vector<string> v; void go(int l) { int i; if (l > t) { for (i = 1; i <= t; i++) res += ss[d[i] - 1]; v.push_back(res); res = ""; retur...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int di[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dj[] = {1, -1, 0, 0, -1, 1, 1, -1}; const int N = 55; int n, m; char grid[N][N]; map<char, int> info; string inst; bool valid(int i, int j) { return i >= 0 && i < n && j >= 0 && j < m && grid[i][j] != '#'; } bool canReach(int i,...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
n, m = map(int, input().split()) a = [] startx = 0 starty = 0 for i in range(n): a.append(input()) if ("S" in a[i]): startx = a[i].index('S') starty = i s = input() ans = 0 for l in range(4): for r in range(4): if r == l: continue for u in range(4): if u ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
from itertools import permutations a=[] for i in permutations("EWNS"): a.append("".join(i)) # print(len(a)) ans=0 n,m=map(int,input().split()) arr=[] for i in range(n): arr.append(input()) if "S" in arr[-1]: indx=i indy=arr[-1].index("S") def check(x,y,sign): x1=x y1=y ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.*; import java.io.*; public class GoodBye2017_B { static int n, m; static char[][] grid; public static boolean isValid(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m && grid[x][y] != '#'; } public static void main(String[] args) throws IOException { Scanner sc = new Scanner(S...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int direction[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int mapping[24][4] = {{0, 1, 2, 3}}; char maze[51][51]; char inst[101]; int main() { for (int i = 1; i < 24; i++) { memcpy(&mapping[i], &mapping[i - 1], sizeof(int) * 4); next_permutation(&(mapping[i][0]), ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; void dor(int *x, int *y, int o) { if (o == 68) { *x = *x + 1; } if (o == 76) { *y = *y - 1; } if (o == 85) { *x = *x - 1; } if (o == 82) { *y = *y + 1; } } int main() { int n, m; char a[24][4] = { {'D', 'L', 'U', 'R'}, {'D', 'L', 'R...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
//package javaapplication1; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.lang.reflect.Array; import static java.lang.reflect.Array.set; im...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; public class Solution { ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> double EPS = 0.00000001; const long long INF = 1000000007; using namespace std; int main() { int n, m; cin >> n >> m; vector<string> a(n); pair<int, int> st, en; for (int i = (0); i < (n); ++i) { cin >> a[i]; for (int j = (0); j < (m); ++j) { if (a[i][j] == 'S') { ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.*; public class Bot { static ArrayList<String> arr = new ArrayList(); public static boolean test(char c[][],String map,int n,int m,int sri,int srj,int eri,int erj) { int flag = 0; //System.out.println(sri+" "+srj+" "+eri+" "+erj); for(int i=0;i<map.length();i++) { if(map.charAt(i)=='U') ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
n,m=map(int,raw_input().split()) lst=[] for i in range(0,n): st=str(raw_input()) lst.append(st) #print lst for i in range(0,n): for j in range(0,m): if lst[i][j]=="S": poxx=j +1 poyy=i+1 for i in range(0,n): for j in range(0,m): if lst[i][j]=="E": epx =j +1 epy=i+1 #pri...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
n, m = map(int, input().split()) s = [] for i in range(0, n): s.append(str(input())) inst = str(input()) sr = 0 sc = 0 for i in range(0, n): for j in range(0, m): if s[i][j] == 'S': sr = i sc = j success = 0 for up in range(0, 4): for down in range(0, 4): if up == do...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
def translate(perm, num): for i in range(len(perm)): if perm[i] == num: return i import itertools inp = input().split(" ") h = int(inp[0]) w = int(inp[1]) maze = [[0 for x in range(w)] for y in range(h)] startx = -1 starty = -1 for k in range(h): inp = input() for i in range(w): ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
def check(dire, l, start, end): n,m = len(l), len(l[0]) nn = len(dire) for i in range(nn): if dire[i] == 'E': if start[1]+1 >=m: return False else: start = [start[0], start[1]+1] if dire[i] == 'W': if start[1]-1 <0: ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 55; const int MAXL = 105; int n, m, l, cnt; pair<int, int> st, en, place; char Map[MAXN][MAXN], str[MAXL]; int nxt[2][2]; int main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { scanf(" %c", &Map[i][j]);...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; vector<vector<int>> perm; void generate(vector<int>& curr, int n) { if (n == 4) perm.push_back(curr); else { for (int i = n; i < 4; i++) { swap(curr[n], curr[i]); generate(curr, n + 1); swap(curr[n], curr[i]); } } } bool yes(vector<string...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 5; int n, m; map<int, int> dir; char s[200][200]; bool ok; int b[200]; void dfs(int x, int y, int i) { if (x < 1) return; if (x > n) return; if (y < 1) return; if (y > m) return; if (s[x][y] == '#') return; if (s[x][y] == 'E') { ok = true...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; void ins(string &s) { getline(cin, s); } int to_num(string s) { return atoi(s.c_str()); } long long power(long long x, long long y) { long long temp; if (y == 0) return 1; temp = power(x, y / 2) % MOD; if (y % 2 == 0) return (temp % MOD ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; char ch[n + 2][m + 2]; int i, j; for (i = 0; i < n + 2; i++) { ch[i][0] = '#'; ch[i][m + 1] = '#'; } for (i = 0; i < m + 2; i++) { ch[0][i] = '#'; ch[n + 1][i] = '#'; } for (i = 1; i <= n; i++) { fo...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), m = in.nextInt(); String[] a = new String[n]; int is,js,ie,je,it,jt; is=js=ie=je=it=jt=0; for(int i=0;i...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; const int N = 105; char a[N][N]; int p[N]; string s; int n, m, sx, sy, ex, ey, ans; void Follow() { int len, i, x, y; x = sx; y = sy; len = s.size(); for (i = 0; i < len; i++) { if ((s[i] - '0') == p[0]) x--; if ((s[i] - '0') == p[1]) x++; if ((s[i] - ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.ArrayList; import java.util.HashMap; import java.util.Scanner; public class BuggyBot { static String[] permu = { "0123", "0132", "1023", "1032", "0213", "0312", "0231", "0321", "1203", "1230", "1302", "1320", "2013", "2103", "2130", "2031", "2301", "2310", "3210", "3201", "3102", "3120", "3012", "...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import itertools as it n, m = map(int, input().split()) board = [['#' for _ in range(m + 2)]] for _ in range(n): board += [['#'] + list(input()) + ['#']] board += [['#' for _ in range(m + 2)]] route = input() #for line in board: # print(line) D = { 0 : (-1, 0), 1 : (1, 0), 2 : (0, -1), 3 :...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int n, m; int a[55]; int perm[4]; char mp[55][55]; char str[105]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%s", mp[i]); for (int i = 0; i < 4; i++) perm[i] = i; scanf("%s", str); int len = strlen(str); int stx, sty; for (int i = 0...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import sys #f = open('input', 'r') f = sys.stdin ms = tuple(map(int, f.readline().split())) d = [(0, 1), (0, -1), (1, 0), (-1, 0)] mp = [] for i in range(ms[0]): mp.append(f.readline().strip()) for j in range(ms[1]): if mp[i][j] == 'S': start_pos = (i, j) elif mp[i][j] == 'E': end_pos = (i, j) ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int n, m, stI, stJ, ans = 0, arr[4] = {0, 1, 2, 3}; char grid[50][50]; string s; bool isValid(int x, int y) { if (x >= n || x < 0 || y >= m || y < 0 || grid[x][y] == '#') return 0; return 1; } void solve(int x, int y) { for (int i = 0; i < s.size(); i++) { if (arr...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 1e3 + 5; const double eps = 1e-9; using namespace std; int arr[MAXN][MAXN]; int vis[MAXN][MAXN]; char tmp[MAXN]; pair<int, int> st, en; int n = 0, m = 0, flag = 0; int dx[] = {1, 0, -1, 0}; int dy[] =...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; char mapa[123][123]; int n, m; pair<int, int> S; string moves; int result; char per[] = {'0', '1', '2', '3'}; bool czy(char U, char D, char L, char R, int p_i, int p_j) { for (int i = 0; i < moves.size(); i++) { if (moves[i] == U) p_i--; else if (moves[i] ==...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
dx = [0,1,0,-1] dy = [-1,0,1,0] n,m = map(int, raw_input().split()) grid = [raw_input() for __ in range(n)] dd = map(int, raw_input()) def check(mm): sx = 0 sy = 0 for i in range(n): for j in range(m): if grid[i][j] == 'S': sx = i sy = j for x in dd: g = mm[x] sx += dx[g] ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; const long long int sz = 1e5 + 5; const long long int szz = 1e6 + 6; const long long int mod = 1e9 + 7; long long int dx[4] = {1, 0, -1, 0}; long long int dy[4] = {0, 1, 0, -1}; int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); clock_t ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.*; public class C908 { public static void main(String[] args) { new Task().solve(); } static class Task { Scanner in = new Scanner(System.in); public void solve() { int rows = in.nextInt(); int cols = in.nextInt(); char[][] maze = new c...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
x,y=raw_input().strip().split() n,g=int(x),int(y) l5=[[0 for i in range(g)] for j in range(n)] def path(u,d,r,l): i=a1 j=b1 m=1 global count for t in s: if int(t)==u: i=i+1 if int(t)==d: i=i-1 if int(t)==r: j=j+1 if int(t)==l: ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class B { public static void main(String[] args) { FastScanner scan = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int n = scan...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; import static java.lang.Math.*; public class Sol implements Runnable { static long mod = 1000000007; char board[][]; int count, x, y, n, m; String directions; boolean check(char c[], int l, int r, int ind) { if...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; const int mx = 55; char grid[mx][mx]; pair<int, int> init, finish; int n, m; string instr; pair<int, int> eval(char ch) { map<char, int> mp; string dir = "DLUR"; int idx = -1; for (int i = 0; i < 4; i++) if (dir[i]...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
from itertools import permutations N,M = map(int,input().split(" ")) arr = [['a'] for _ in range(N)] for i in range(N): arr[i] = list(input()) if 'S' in arr[i]: start = [arr[i].index('S'),i] if 'E' in arr[i]: end = [arr[i].index('E'),i] s = input() ans = 0 start_copy = start[:] for pattern in permutations([...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pradyumn */ public class M...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; char a[55][55]; bool d[4]; long long l[4]; long long n, m; pair<long long, long long> S, E; string str; long long ans = 0; void check() { bool flag = 0; if (l[0] == 1 && l[1] == 2 && l[2] == 0 && l[3] == 3) flag = 1; pair<long long, long long> T = S; for (long long ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import sys import random import functools import re import itertools import math import copy import bisect import Queue from collections import Counter sys.setrecursionlimit(1000000) def debug(*_): for x in _: print >> sys.stderr, x, print >> sys.stderr if __name__ == "__main__": n, m = [int(_) ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; /** * Created by cscvenkatmadurai on 12/14/2016. */ public class Qn1 { InputStream is; PrintWriter out; String INPUT...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int r, c, myint[] = {0, 1, 2, 3}; char d[51][51], next_col[] = {0, 1, 0, -1}, next_row[] = {-1, 0, 1, 0}; string h; int dfs(int i, int j, int l) { if (l >= h.length()) return 0; i = i + next_row[myint[h[l] - 48]]; j = j + next_col[myint[h[l] - 48]]; if (i >= 0 && j ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e6 + 10; const int INF = 1e9 + 7; string st[55]; string p; pair<int, int> S, E; vector<int> a; int n, m; int dirx[] = {-1, +1, 0, 0}; int diry[] = {0, 0, +1, -1}; inline bool check() { pair<int, int> cur = S; for (int i = 0; i < p.size(); i++) { cu...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import itertools n=list(map(int,input().split(" "))) b=[] sind=[] eind=[] obst=[] for i in range(n[0]): asdf=input() b.append([]) for j in range(n[1]): if asdf[j]=="S": sind=[i,j] elif asdf[j]=="E": eind=[i,j] elif asdf[j]=="#": obst.append([i,j]) ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; bool go(char** a, int n, int m, int startR, int startC, string s, string arr[4]) { for (int i = 0; i < s.length(); ++i) { if (s[i] == '0') { if (arr[0] == "up") --startR; else if (arr[0] == "down") ++startR; else if (arr[0] ==...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
def mp(): return map(int,raw_input().split()) n,m=mp() mat=[] z=[] for i in range(n): mat.append(list(raw_input())) mapi=raw_input() z=['0123', '0132', '0213', '0231', '0321', '0312', '1023', '1032', '1203', '1230', '1320', '1302', '2103', '2130', '2013', '2031', '2301', '2310', '3120', '3102', '3210', '3201', '3...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.io.*; import java.lang.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class Main implements Runnable { public static void main(String[] args) { new Thread(null, new Main(), "Check2", 1 << 28).start();// to increse stack ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.HashMap; import java.util.Scanner; public class B { static String [] grid; static String comm; static Tuple start, end; public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); grid = new String[n]; for(int i =...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
n, m = [int(i) for i in input().split()] maps = [] for i in range(n): maps.append([]) s = input() for z in range(m): maps[i].append(s[z]) if s[z] == 'S': bx = z by = i elif s[z] =='E': fx = z fy = i command = input() def req(s, a): ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.util.*; public class B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n, m; n = scan.nextInt(); m = scan.nextInt(); char[][] maze = new char[n][m]; for (int i = 0; i < n; i++) { maze[i] = scan.next().t...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); std::cout.tie(0); int n, m, cou = 0, x, y; cin >> n >> m; char arr[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> arr[i][j]; if (arr[i][j] == 'S') x = i, y = j; ...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import itertools stuff = [int(i) for i in raw_input().split()] n = stuff[0] m = stuff[1] maze = [] for i in xrange(n): maze.append(list(raw_input())) for i in xrange(n): for j in xrange(m): if maze[i][j] == 'S': startx = i starty = j instructions = [int(i) for i in raw_inpu...
Problem: Bob programmed a robot to navigate through a 2d maze. The maze has some obstacles. Empty cells are denoted by the character '.', where obstacles are denoted by '#'. There is a single robot in the maze. Its start position is denoted with the character 'S'. This position has no obstacle in it. There is also a ...
import java.lang.reflect.Array; import java.util.*; public class Main { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int possibilities = 0; int n = Integer.parseInt(in.next()); int m = Integer.parseInt(in.next()); Maze maze = new Maze(n, m...