Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
I=input exec(int(I())*"n=int(I());a=[[*map(ord,I())]for _ in[0]*n];a=a[0][1],a[1][0],a[-2][-1]^1,a[-1][-2]^1;b=*map(a.count,a),;m=b[0]>3or a[b.index(min(b))];r=[y for x,y in zip(a,('1 2','2 1',f'{n-1} {n}',f'{n} {n-1}'))if x==m];print(len(r),*r);")
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys from itertools import permutations from itertools import combinations from itertools import combinations_with_replacement #sys.stdin = open('/Users/pranjalkandhari/Desktop/Template/input.txt', 'r') for _ in range( int(input()) ): n = int(input()) a = '' b = '' c = '' d = '' for i in ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
n = int(input()) for j in range(n): n = int(input()) f=[] for j in range(n): l = input() if n==3: if j==0: f.append(int(l[1])) if j==1: f.append(int(l[0])) f.append(int(l[n-1])) if j==n-...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
from collections import Counter from collections import OrderedDict from collections import defaultdict def freq_count(mylist): return Counter(mylist) t=int(input()) for _ in range(t): n=int(input()) #arr=[int(x) for x in input().split()] #a,b=map(int,input().split()) #print(a^b) grid=[list(inp...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys import math from functools import reduce import bisect def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def input(): return sys.stdin.readline().rstrip() def index(a, x): i = bisect.bisect_left(a,...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void _print(long long t) { cerr << t; } void _print(int t) { cerr << t; } void _print(string t) { cerr << t; } void _print(char t) { cerr << t; } void _print(long double t) { cerr << t; } void _print(double t) { cerr << t; } void _print(unsigned long long t) { cerr << t; } ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
""" Code of Ayush Tiwari Codeforces: servermonk Codechef: ayush572000 """ # import sys # input = sys.stdin.buffer.readline def solution(): # This is the main code n=int(input()) l=[] for i in range(n): a=list(input()) l.append(a) ans=[] if l[1][0]==l[0][1]: if l[n-...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> const long double eps = 1e-8; using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t = 1; cin >> t; while (t--) { long long int n; cin >> n; long long int a[n + 1][n + 1]; string temp; for (long long ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; inline int read() { int n = 0, f = 1, ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { n = n * 10 + ch - '0'; ch = getchar(); } return n * f; } char s[305][305]; int main() {...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
from sys import stdin, stdout from math import gcd input = stdin.readline for _ in range(int(input())): n = int(input()) a = [input() for i in range(n)] ans = [(i, j) for i, j in [(0, 1), (1, 0), (n - 2, n - 1), (n - 1, n - 2)] if (a[i][j] == '0') ^ (min(i, j) == 0)] if len(ans) <= 2: print(len...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) for i in range(t): n=int(input()) grid=[] for j in range(n): grid.append(input()) s1=grid[0][1] s2=grid[1][0] s3=grid[-2][-1] s4=grid[-1][-2] if s1==s2==s3==s4: print(2) print(1,2) print(2,1) elif s1==s2==s3: print(1) pr...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine(...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
# -*- coding: utf-8 -*- """ Created on Sat Sep 19 16:36:57 2020 @author: lakne """ t = int(input()) answers = [] for _ in range(t): n = int(input()) start = [] finish = [] answer = [] grids = [] c = 0 for i in range(n): grid = input() grids.append(grid) start.append(grid...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python2
for _ in range(input()): n=input() l=[] for i in range(n): k=raw_input() l.append(k) sq1=l[0][1] sq2=l[1][0] sq3=l[n-1][n-2] sq4=l[n-2][n-1] switch=[] if sq1==sq2: if sq3==sq1: switch.append([n,n-1]) if sq4==sq1: switch.append([...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
T = int( input() ) for t in range(T): m = [] n = int( input() ) for i in range(n): s = list( input() ) m.append(s) #print(m) p = [ m[1][0], m[0][1], m[n-2][n-1], m[n-1][n-2] ] result = [] if p[0] == p[1]: if p[2] == p[0]: result.append(2) if p[3] == p[0]: result.append(3) ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t = int(input()) for case in range(t): n = int(input()) grid = [input() for row in range(n)] cnt = 0 ans = [] if grid[0][1] == grid[1][0]: g = 1 - int(grid[0][1]) if int(grid[-1][-2]) != g: ans.append((n, n - 1)) if int(grid[-2][-1]) != g: ans.append((...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.*; import javax.swing.plaf.basic.BasicScrollPaneUI.HSBChangeListener; import java.io.*; public class A { static BufferedReader br; static PrintWriter pw; static int inf = (int) 1e9; static long mod = (long) 1e9 + 7; static ArrayList<Integer>[] graph; static int n; static char[][] a; static ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, a[205][205]; char c; cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { cin >> c; a[i][j] = c - '0'; } if (a[1][2] == a[2][1]) { if (a[n - 1][n]...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)] def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)]...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
# Author : devil9614 - Sujan Mukherjee from __future__ import division, print_function import os,sys import math import collections from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip class my_diction...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range (int(input())): n = int(input()) grid = [] for i in range (n): grid.append(list(input())) s1 = grid[0][1] s2 = grid[1][0] e1 = grid[n-2][n-1] e2 = grid[n-1][n-2] ans = [] if s1 == s2: if e1 == s1: ans.append([n-1,n]) if e2 == s2: ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): ans = 0 ind = [[0] * 2 for i in range(4)] n = int(input()) s = [input() for i in range(n)] #0011 if s[1][0] == '1': ans += 1 ind[0][0] = 2 ind[0][1] = 1 if s[0][1] == '1': ans += 1 ind[1][0] = 1 ind[1][1] = 2 i...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void edit(vector<int> &skill, int n) { for (int i = 0; i < n; i++) { int x; cin >> x; skill.push_back(x); } } void achilles() { int n; cin >> n; char arr[n][n]; cin.ignore(); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
def main(input_f): t = int(input_f()) for _ in range(t): n = int(input_f()) cells = [list(input_f()) for _ in range(n)] start_right, start_bottom = cells[0][1], cells[1][0] finish_left, finish_top = cells[n - 1][n - 2], cells[n - 2][n - 1] inverted_cells = [] if s...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int solve() { int n; cin >> n; string s[n]; for (int i = 0; i < n; i++) cin >> s[i]; if (s[0][1] == s[1][0] and s[n - 2][n - 1] == s[n - 1][n - 2] and s[0][1] != s[n - 2][n - 1]) { puts("0"); return 0; } if (s[0][1] == s[1][0]) { if (s[n - 1]...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); for (int t = sc.nextInt(); t-- > 0;) { int n = sc.nextInt(), c = 0; char a[][] = new char[n][n]; for(int i=0;i<n;i++) a[i]=sc.next().toCharArra...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long Min(long long a, long long b) { return (a < b) ? a : b; } long long Max(long long a, long long b) { return (a < b) ? b : a; } long long gcd(long long m, long long n) { if (n == 0) return m; return gcd(n, m % n); } long long lcm(long long m, long long n) { retu...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
def getInverts(arr,N): inverts = [] if arr[0][1] == arr[1][0]: if arr[-1][-2] == arr[0][1]: inverts.append([N-1,N-2]) if arr[-2][-1] == arr[0][1]: inverts.append([N-2,N-1]) else: if arr[-1][-2] == arr[-2][-1]: if arr[0][1] == arr[-1][-2]: ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.*; import java.math.*; import java.io.*; public class B{ static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while (st ==...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int t, sr, sl, eu, ele; cin >> t; while (t--) { int n; scanf("%d", &n); getchar(); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { char c = getchar(); if (i == 1 && j == 2) sr = c - '0'; if (i ==...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = nextInt(); for (int...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for w in range(int(input())): n=int(input()) l=[] for i in range(n): l.append(list(str(input()))) #print(l) if(l[0][1]==l[1][0]): if(l[n-1][n-2]==l[n-2][n-1]): if(l[n-1][n-2]==l[0][1]): print(2) print(n,n-1) print(n-1,n) ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n=int(input()) l=[input() for i in range(n)] #print(l) if l[0][1]==l[1][0]: if l[-1][-2]==l[-2][-1]: if l[-1][-2]!=l[1][0]: print(0) else: print(2) print(1,2) print(2,1) ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) for i in range(t): n=int(input()) m=[[i for i in input()] for i in range(n)] #print(m) q=int(m[1][0]) w=int(m[0][1]) a=int(m[-1][-2]) s=int(m[-2][-1]) e=n-1 if q == w: if a == s: if q == a: print('2','\n','1 2','\n','2 1',sep='') ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void solve() { int n; string s; vector<string> v; cin >> n; for (int i = (0); i < int(n); i++) { cin >> s; v.push_back(s); } vector<pair<int, int> > ans; if (v[0][1] == v[1][0]) { if (v[n - 1][n - 2] == v[0][1]) ans.push_back({n - 1, n - 2}); ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys input = lambda: sys.stdin.readline().rstrip() t = int(input()) for _ in range(t): n = int(input()) s = [] for _ in range(n): s.append(input()) x0, x1, x2, x3 = int(s[0][1]), int(s[1][0]), int(s[-1][-2]), int(s[-2][-1]) ans = [] if x0==1: ans.append((1, 2)) if x1==1...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys import math from math import * from collections import Counter,defaultdict,deque from bisect import bisect_left import random lip = lambda : list(map(int, input().split())) ip = lambda : int(input()) sip = lambda : input().split() mod = 10**9+7 def main(): n = ip() mat = [] for i in range...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t = int(input()) for _ in range(0,t): n = int(input()) s = [] for i in range(0,n): ss = [k for k in input()] s.append(ss) ans = [] kk = [s[0][1],s[1][0],s[-2][-1],s[-1][-2]] z,o = kk.count('0'),kk.count('1') if z == 0 or o == 0: ans.append([1,2]) ans.appe...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char mp[300][300]; int n; void solve() { int cnt = 0; if ((mp[1][2] - '0') && (mp[2][1] - '0')) { cnt = 0; if (mp[n][n - 1] - '0') { cnt++; } if (mp[n - 1][n] - '0') { cnt++; } printf("%d\n", cnt); if (mp[n][n - 1] - '0') { ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char s[205][205]; int main() { int t, n; scanf("%d", &t); while (t--) { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1); vector<pair<int, int>> ans[2]; ans[s[1][2] == '1'].push_back(make_pair(1, 2)); ans[s[2][1] == '1'].push_bac...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
def main(): n = int(input()) s1, s2, e1, e2 = 0, 0, 0, 0 for i in range(n): row = input() if i == 0: s1 = row[1] elif i == 1: s2 = row[0] if i + 2 == n: e1 = row[n-1] elif i + 1 == n: e2 = row[n-2] if s1 == s2: ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n = int(input()) x = [] for i in range(n): x.append(list(input())) if x[0][1] == x[1][0] and x[-1][-2] == x[-2][-1]: if x[0][1] != x[-1][-2]: print(0) else: print(2) print(1, 2) print(2, 1) elif x[0...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys from collections import defaultdict as dd from collections import Counter as cc from queue import Queue import math import itertools try: sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') except: pass # input = lambda: sys.stdin.buffer.readline().rstrip() for _ in range(int(input(...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long T, n, i, j; long long S_0, S_1, F_0, F_1, count; cin >> T; while (T--) { cin >> n; string A[n]; for (i = 0; i < n; i++) { cin >> A[i]; } S_0 = 0; S_1 = 0; F...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.io.*; import java.math.*; import java.util.*; // printArr() - prints the array // intList, doubleList, longList // nextIntArray /* stuff you should look for * int overflow, array bounds * special cases (n=1?) * do smth instead of nothing and stay organized * WRITE STUFF DOWN */ public class current ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
from sys import stdin for _ in range(int(stdin.readline())): side = int(stdin.readline()) board = [] for i in range(side): board.append(stdin.readline().strip()) a = board[0][1] b = board[1][0] c = board[side-2][side-1] d = board[side-1][side-2] if a == b: if a == "1": ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t = int(input()) for _ in range(t): ans = [] final = [] n = int(input()) for i in range(n): s = input() lol = list(s) ans.append(s) a = ans[0][1] b = ans[1][0] x = ans[n-2][n-1] y = ans[n-1][n-2] #print(a,b,x,y) if(b != '0'): final.append...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) for i in range(t): n=int(input()) L=[] for i in range(n): ch=input() L.append(ch) I=[] if (int(L[0][1])+int(L[1][0]))%2==0: if L[n-1][n-2]==L[1][0]: I.append((n,n-1)) if L[n-2][n-1]==L[1][0]: I.append((n-1,n)) e...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long n; cin >> n; char arr[n][n]; for (long long i = 0; i < n; i++) for (long long j = 0; j < n; j++) cin >> arr[i][j]; bool f = f...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long T, N, M, ans, temp; char m[200][2001]; int main(void) { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); cin >> T; for (long long t = 1; t <= T; t++) { cin >> N; for (long long i = 0; i < N; i++) { cin >> m[i]; } vector<pai...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.*; import java.lang.*; // https://codeforces.com/contest/1421/problem/B public class B1421 { static Scanner sc; public static void solve() { int n = sc.nextInt(); int[][] map = new int[n][n]; for(int i = 0; i < n; i++) { char[] s = sc.next().toCharArray(); for(int j = 0; j < n; j++) { ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string mp[210]; int n; bool func(char x, char y) { int res = (mp[1][0] == x) + (mp[0][1] == x) + (mp[n - 1][n - 2] == y) + (mp[n - 2][n - 1] == y); if (res <= 2) { cout << res << "\n"; if (mp[1][0] != y) cout << "2 1" << "\n"; if...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.List; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; import java.util.ArrayList; ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): a = [] for i in range(int(input())): a.append(input()) if a[0][1] == "1" and a[1][0] == "1" and a[-1][-2] == "1" and a[-2][-1] == "1" or a[0][1] == "0" and a[1][0] == '0' and a[-1][-2] == "0" and a[-2][-1] == "0": print(2) print(1, 2) print(2, 1)...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys, math import io, os #data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from bisect import bisect_left as bl, bisect_right as br, insort from heapq import heapify, heappush, heappop from collections import defaultdict as dd, deque, Counter #from itertools import permutations,combinations def data(): ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
from collections import Counter import math import sys from bisect import bisect,bisect_left,bisect_right from itertools import permutations def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, o = 0, c = 0; cin >> n; vector<vector<char>> V(n, vector<char>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> V[i][j]; } if (V[1][0] == V[0][1] && V[n - 1][n - 2] =...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
def solve(n, grid): pos = [] if grid[0][1] == grid[1][0]: if grid[n - 1][n - 2] == grid[0][1]: pos.append((n - 1, n - 2)) if grid[n - 2][n - 1] == grid[0][1]: pos.append((n - 2, n - 1)) elif grid[n - 1][n - 2] == grid[n - 2][n - 1]: if grid[0][1] == grid[n - 1...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n, t; char s[205][205]; int main() { cin >> t; int i, j, k; while (t--) { cin >> n; for (i = 1; i <= n; ++i) { cin >> (s[i] + 1); } int cnt = 0; bool i1 = 0, i2 = 0; if (s[1][2] == s[2][1]) { if (s[n][n - 1] == s[1][2]) { ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n=int(input()) s=input() c1=s[1] s=input() c2=s[0] for i in range(max(n-4,0)): s=input() if n==3: c3=s[n-1] s=input() c4=s[n-2] else: s=input() c3=s[n-1] s=input() c4=s[n-2] if c1==c2: ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
test_cases = range(int(input())) for test_case in test_cases: n = int(input()) grid = [] for i in range(n): new_line = [c for c in input()] grid.append(new_line) sr, sd = grid[0][1], grid[1][0] fl, fu = grid[n-1][n-2], grid[n-2][n-1] if sr == sd and fl == fu and s...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int t; int n; int list[201][201]; cin >> t; while (t > 0) { t--; cin >> n; char qwe; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if ((i == 0 && j == 0) || (i == (n - 1) && j == (n - 1))) { cin >>...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; clock_t time_p = clock(); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { long long n; cin >> n; char s[n + 1][n + 1]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 210; char s[maxn][maxn]; bool vis[maxn][maxn]; int d[][2] = {1, 0, -1, 0, 0, 1, 0, -1}; int n; bool dfs(int x, int y, char ch) { for (int i = 0; i < 4; ++i) { int nx = x + d[i][0], ny = y + d[i][1]; if (nx == n && ny == n) return 1; if (nx < 1...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n = int(input()) l = [] for i in range(n): l.append(list(str(input()))) l2 = [] a1 = 0 a2 = 0 a3 = 0 a4 = 0 c = 0 a1+=2 - ((int(l[0][1])) + (int(l[1][0]))) a2+=((int(l[0][1])) + (int(l[1][0]))) a3 = 2 - ((int(l[n-1][n-2])) + (int(l[n-...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> #pragma warning(disable : 4996) template <typename T> T min(T x, T y) { return x < y ? x : y; } template <typename T> T max(T x, T y) { return x > y ? x : y; }; const long long INF = 20000000050000; const long long mod = 998244353; const long long MAXN = 205; int N; char s[MAXN][MAXN]; void...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); int loo...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import itertools import sys from typing import List sys.setrecursionlimit(10 ** 9) def lmi(): return list(map(int, input().split())) def main(): for _ in range(int(input())): n = int(input()) grid = [list(input()) for _ in range(n)] result = solve(n, grid) print(len(result))...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
from sys import * input = stdin.readline for _ in range(int(input())): n = int(input()) matrix = [] for i in range(n): a = [] s = input() for em in s[:-1]: if(em == 'S' or em == 'F'): a.append(em) else: a.append(int(e...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) for _ in range(t): n=int(input()) l=[] for i in range(n): l.append(input()) if l[0][1]==l[1][0]: if l[-2][-1]==l[-1][-2]: if l[-2][-1]!=l[0][1]: print(0) else: print(2) print(n-1,n) pri...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
#include <CodeforcesSolutions.h> #include <ONLINE_JUDGE <solution.cf(contestID = "1421",questionID = "A",method = "GET")>.h> """ Author : thekushalghosh Team : CodeDiggers I prefer Python language over the C++ language :p :D Visit my website : thekushalghosh.github.io """ import sys,math,cm...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.*; public class B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); for(int tt = 0;tt<t;tt++) { int n = scan.nextInt(); scan.nextLine(); int s1,s2,f1,f2; String s = scan.nextLine(); s1 = Integer.parseInt(Character.toSt...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
// package com.company; import java.util.*; import java.lang.*; import java.io.*; //****Use Integer Wrapper Class for Arrays.sort()**** public class FR2 { static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); public static void main(String[] Args)throws Exception{ FastReader scan=n...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
def flip(n): if n=='0': return '1' else: return '0' def hi(a): n = len(a) c = 0 f = [] if a[0][1]==a[1][0] and a[n-1][n-2]==a[n-2][n-1] and a[0][1]!=a[n-1][n-2]: return c,[] if a[0][1]==a[1][0]: p = a[0][1] if a[n-1][n-2]==p: a[n-1][n-2] = flip(p) c+=1 f.append([str(n),str(n-1)]) if a[n-2]...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; char ch[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> ch[i][j]; int co = 0; pair<i...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python2
from __future__ import division, print_function ''' Hey stalker :) ''' INF = 10 ** 10 TEST_CASES = True from collections import defaultdict, deque, Counter from functools import reduce from bisect import bisect_left def main(): n = get_int() mat = [list(input()) for _ in range(n)] indexes = [(1,0), (0,1)...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { int N; cin >> N; int a[N][N]; for (int i = 0; i < N; i++) { string s; cin >> s; for (int j = 0; j < s.size(); j++) a[i][j] = s[j] - '0'; } vector<pair<int, int>> targets; targets...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
from collections import Counter,defaultdict I =lambda:int(input()) M =lambda:map(int,input().split()) LI=lambda:list(map(int,input().split())) for _ in range(I()): n=I() a=[] for i in range(n): s=input() s=list(s) a+=[s] ans = [] if a[0][1] == a[1][0]: x = a[0][1] ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python2
#!/usr/bin/env python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip def main(): t = int(input()) for _ in range(t):...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import math as mt import bisect import sys #input=sys.stdin.readline t=int(input()) import collections import heapq #t=1 p=10**9+7 def ncr_util(): inv[0]=inv[1]=1 fact[0]=fact[1]=1 for i in range(2,300001): inv[i]=(inv[i%p]*(p-p//i))%p for i in range(1,300001): inv[i]=(inv[i-1]*inv[i])%...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) for _ in range(t): n=int(input()) f=[] for i in range(n): f.append(str(input())) a=f[1][0] b=f[0][1] c=f[-1][-2] d=f[-2][-1] if a==b: if c==d: if a!=c: print(0) else: print(2) pri...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n = int(input()) a = [] for i in range(n): x = input() s = [i for i in x] a.append(s) if a[0][1] == a[1][0]: if a[-1][-2] == a[-2][-1] == a[0][1]: print(2) print(n,n-1) print(n-1,n) elif a[0][1] == ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys input=sys.stdin.readline for _ in range(int(input())): n=int(input()) # a,b=map(int,input().split()) # s=input().strip() # a=list(map(int,input().split())) g=[] ans,ans1=[],[] for i in range(n):g.append(input()) s1,s2=g[0][1],g[1][0] e1,e2=g[n-1][n-2],g[n-2][n-1] if s1==s2=='0': if e1=='0': an...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for t in range(int(input())): n=int(input()) mat=[] for i in range(n): mat.append(list(input())) out=0 ans=[] if mat[0][1]==mat[1][0]: if mat[-1][-2]==mat[0][1]: out+=1 ans.append([n,n-1]) if mat[n-2][n-1]==mat[0][1]: out+=1 ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys import math from collections import defaultdict,Counter input=sys.stdin.readline # def print(x): # sys.stdout.write(str(x)+"\n") # sys.stdout=open("CP2/output.txt",'w') # sys.stdin=open("CP2/input.txt",'r') # mod=pow(10,9)+7 t=int(input()) for i in range(t): n=int(input()) for j in range(n): s=inp...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
# import sys; input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**7) from collections import defaultdict mod = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) def main(): T = int(input()) for _ in range(T): N = int(input()) L = [] for i in range(N): l = list...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.Scanner; public class CodeForces1810 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i<t; i++) { System.out.println(algo(sc)); } } public static String algo(Scanner sc) { int ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n = int(input()) arr = [list(input()) for _ in range(n)] res = [] if arr[n-2][n-1] == arr[n-1][n-2]: if arr[0][1] == arr[n-2][n-1]: res.append((1, 2)) if arr[1][0] == arr[n-2][n-1]: res.append((2, 1)) elif arr[0][1] == arr[1][0]: ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t = int(input()) for _ in range(t): n = int(input()) A = [] for _ in range(n): A.append(input()) if A[0][1] == A[1][0] and A[-1][-2] == A[-2][-1]: # 4 cases if A[0][1] != A[-1][-2]: print(0) else: print(2) print(1, 2) print(2, 1) ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
# your code goes here for _ in range(int(input())): n=int(input()) a=[[-1]*n for z in range(n)] for z in range(n): a[z]=list(input()) ansx=[] if a[0][1]==a[1][0]: v=a[0][1] if a[-1][-2]==v: ansx.append([n,n-1]) if a[-2][-1]==v: ansx.append([n-1...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
def process(): n=int(input()) li=[] for i in range(n): li.append(list(input())) ans=[] if(li[0][1]!=li[1][0] and li[n-1][n-2]!=li[n-2][n-1]): if(li[0][1]!='0'): ans.append((0,1)) if(li[1][0]!='0'): ans.append((1,0)) if(li[n-1][n-2]!='1'): ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main implements Runnable { int INF = (int) 1e9 + 7; List<Integer> edges[]; int anc[][]; boolean...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) while t>0: t-=1 n=int(input()) a=[] for i in range(n): b=input() a.append(b) c=int(a[0][1]) d=int(a[1][0]) e=int(a[-1][-2]) f=int(a[-2][-1]) if c==d and e==f and c!=e: print(0) elif c==d and e==f and c==e: print(2) print(1,2)...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.List; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.ut...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
def main(): for i in range(int(input())): n = int(input()) matx = [] for i in range(n): x = list(input()) matx.append(x) x = matx[n-2][n-1] y = matx[n-1][n-2] a = matx[0][1] b = matx[1][0] v=a+b+x+y if v=='0100' or v=='1...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.*; import java.lang.*; public class Sam{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int tc=0 ;tc<t;tc++){ int n = in.nextInt(); in.nextLine(); St...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
''' Auther: ghoshashis545 Ashis Ghosh College: jalpaiguri Govt Enggineering College ''' from os import path import sys from heapq import heappush,heappop from functools import cmp_to_key as ctk from collections import deque,defaultdict as dd from bisect import bisect,bisect_left,bisect_right,insort,insort_left...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void fast() { std::ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } char mat[201][201]; int main() { fast(); int n, t; bool p, q; cin >> t; for (int cas = 0; cas < t; cas++) { int x = 0; q = p = false; cin >> n; for (int i = 0; i < n;...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
'''Author- Akshit Monga''' t=int(input()) for _ in range(t): n=int(input()) mat=[[0for y in range(n)] for x in range(n)] for i in range(n): s=input() for j in range(n): mat[i][j]=s[j] if mat[0][1]==mat[1][0]=='0': if mat[n-2][n-1]==mat[n-1][n-2]=='1': prin...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size n× n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.*; import java.io.*; import java.lang.*; public class Codeforces{ BufferedReader br =new BufferedReader(new InputStreamReader(System.in)); PrintWriter out =new PrintWriter(System.out); StringTokenizer st =new StringTokenizer(""); String next(){ if(!st.hasMoreTokens()){ ...