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
import sys,bisect,string,math,time,functools,random,fractions from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter from itertools import permutations,combinations,groupby rep=range;R=range def Golf():n,*t=map(int,open(0).read().split()) def I():return int(input()) def S_():return...
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.util.*; public class Solution { static ArrayList<ArrayList<Integer>> list; static int count=0; public static void main(String[] args) { FastReader fr=new FastReader(); int t=fr.nextInt(); ...
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 random import * #from bisect import * #from collections import deque pl=1 #from math import * from copy import * if pl: input=sys.stdin.readline else: sys.stdin=open('input.txt', 'r') sys.stdout=open('outpt.txt','w') def li(): return [int(xxx) for xxx in input().split()] def fi(): return int(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
def check(l,s,c): if l[0][1]==l[1][0]: x=l[0][1] a=l[n-1][n-2] b=l[n-2][n-1] if a==x: c=c+1 s.append([n,n-1]) if b==x: c=c+1 s.append([n-1,n]) print(c) for i in s: print(*i) return a=l[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 solve(): n = int(input()) grid = [] for _ in range(n): grid.append(input()) g01 = grid[0][1] g10 = grid[1][0] g_12 = grid[n-1][n-2] g_21 = grid[n-2][n-1] if g01 == g10: if g_12 == g_21: if g01 == g_12: print("2") print("...
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 sol() { long long n; cin >> n; char a; long long flag1 = 0, flag2 = 0, flag3 = 0, flag4 = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a; if (i == 0 && j == 1) { if (a == '1') flag1++; } if (i == 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; const int N = 1e5 + 40; vector<int> used(N, 0); void solve() { int n; cin >> n; char a[n + 2][n + 2]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> a[i][j]; } } int b1; b1 = (a[n - 1][n] == '1') + (a[n][n - 1] == '1'); 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
import sys def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s + '\n') def wi(n): sys.stdout.write(str(n) + '\n') def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n') import m...
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.*; public class b { public static void print(String str,long val){ System.out.println(str+" "+val); } public long gcd(long a, long b) { if (b==0L) return a; return gcd(b,a%b); } public static void debug(long[][] arr){ int 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
for _ in range(int(input())): n=int(input()) data=[] for q in range(n): data.append(input()) start_right=data[0][1] start_down=data[1][0] end_left=data[-1][-2] end_top=data[-2][-1] if(start_right==start_down): if(end_left==end_top): if(start_down==end_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
java
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static int MOD = 1000000007; // After writing solution, quick scan for: // array out of bounds // special cases e.g. n=1? // // Big numbers arithmetic bugs: // int overflow // sorting, or tak...
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): grid = [] n = int(input()) for j in range(n): grid.append(input()) a = grid[0][1] b = grid[1][0] c = grid[n - 2][n - 1] d = grid[n - 1][n - 2] if a == b and c == d and b == c: print(2) print("1 2") print("2 1") elif ...
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 _grid[300][300], grid[300][300]; long long vis[300][300]; long long n, m; long long di[] = {0, 0, -1, 1}; long long dj[] = {-1, 1, 0, 0}; bool isPos(long long i, long long j) { return (i >= 0 and j >= 0 and i < n and j < n and !vis[i][j]); } void dfs(long long i, lon...
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.math.*; public class CP{ public static OutputStream out=new BufferedOutputStream(System.out); static Scanner sc=new Scanner(System.in); static long MOD=998244353l; static int INF=10000000; static long[] fact; static long[] inv_fact; static int[] rr=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> using namespace std; int main() { ios_base::sync_with_stdio(false); long long t; cin >> t; long long n; long long ans = 0; long long f1 = 0, f2 = 0; while (t--) { f1 = f2 = 0; ans = 0; cin >> n; string s = ""; string t = ""; for (long long i = 0; i < n; 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 # import threading # threading.stack_size(2**27) import sys sys.setrecursionlimit(10**4) # sys.stdin = open('inpy.txt', 'r') # sys.stdout = open('outpy.txt', 'w') from sys import stdin, stdout import bisect #c++ upperbound import math import heapq i_m=922337203...
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 cf; import java.io.*; import java.util.*; import java.util.jar.JarOutputStream; public class Temp_Class { static int p=1000000007; static class pr { int x; int y; public pr(int x, int y) { this.x = x; this.y = y; } } public static void ma...
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[205][205]; int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> mp[i][j]; } } queue<pair<int, int>> q; if (mp[2][1] == mp[1][2]) { 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.util.*; import java.io.*; import java.math.*; public class Main { static PrintWriter pw = new PrintWriter(System.out); public static void main(String[] args) throws IOException, InterruptedException { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextIn...
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.*; public class Putting_Bricks_In_The_Wall { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try {...
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()) import itertools for _ in range(t): n = int(input()) S = [list(str(input())) for _ in range(n)] flag = False s = [] # 0 s.append((0, 0)) visit0 = [[-1]*n for _ in range(n)] while s: i, j = s.pop() for di, dj in (-1, 0), (1, 0), (0, -1), (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
java
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import...
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) { final Scanner in = new Scanner(System.in); m: for (int tt = in.nextInt(); tt > 0; tt--) { final int n = in.nextInt(); final char[][] map = new char[n][]; for (int y = 0; y < n; y++) { map[y] = in.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; const long long N = 205; char a[N][N]; void Main() { long long n; cin >> n; for (long long i = 1; i <= n; i++) for (long long j = 1; j <= n; j++) { cin >> a[i][j]; } vector<pair<long long, long long> > res; if (a[1][2] == a[2][1]) { char c = 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
java
import java.io.*; import java.util.*; /* polyakoff */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int oo = (int) 1e9 + 10; static final long OO = (long) 2e18 + 20; static final int MOD = (int) 1e9 + 7; static void 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
python3
def main(): for _ in range(int(input())): n=int(input()) matx=[] for j in range(n): matx.append([str(x) for x in input()]) x=[int(matx[0][1]),int(matx[1][0])] y=[int(matx[n-1][n-2]),int(matx[n-2][n-1])] if x==[0,0] and y==[1,1 ]: print(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
def solve(n,m): #print(n,m) a = m[0][1] b = m[1][0] c = m[n-1][n-2] d = m[n-2][n-1] res = [] if a ==b: if a == c: res.append([n,n-1]) if a == d: res.append([n-1,n]) elif c == d: if c == a: res.append([1,2]) if 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
from math import * import sys from sys import stdin from sys import stdout # input = stdin.readline for __ in range(int(input())): n=int(input()) ar=[] for i in range(n): ar.append(input()) a=ar[0][1] b=ar[1][0] x=ar[n-1][n-2] y=ar[n-2][n-1] if(a==b and x==y and a!=x): print(0) elif(a==b==x==y): print(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; vector<pair<int, int>> foo(string table[], int n, char character) { vector<pair<int, int>> result(0); char ch = character; if (table[n - 1][n - 3] != ch) result.push_back({n - 1, n - 3}); if (table[n - 2][n - 2] != ch) result.push_back({n - 2, n - 2}); if (table[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> using namespace std; bool isprime(int64_t n) { for (int64_t i = 2; i * i <= n; ++i) { if (n % i == 0) { return false; } } return true; } int64_t factorial(int64_t n) { return (n == 1 || n == 0) ? 1 : n * factorial(n - 1); } int64_t gcd(int64_t a, int64_t b) { if (a == 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; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t, n; cin >> t; while (t--) { cin >> n; string s[n]; for (int i = 0; i < n; i++) { cin >> s[i]; } if (s[0][1] == s[1][0]) { if (s[n - 1][n - 2] == s[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> const long long INF = 1e18; const long long mod = 1e9 + 7; using namespace std; void solve() { long long n; cin >> n; vector<vector<char>> vec(n, vector<char>(n)); for (long long i = 0; i < n; i++) { for (long long j = 0; j < n; j++) { cin >> vec[i][j]; } } long long 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
python3
# cook your dish here for _ in range(int(input())): n=int(input()) a=[] for i in range(n): a.append(input()) l=[] if a[0][1]==a[1][0]: if a[-2][-1]==a[0][1]: l.append([n-1,n]) if a[-1][-2]==a[0][1]: l.append([n,n-1]) else: if a[-1][-2]==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; inline int rd() { int x = 0; bool f = 0; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = 1; c = getchar(); } while (isdigit(c)) { x = x * 10 + (c ^ 48); c = getchar(); } return f ? -x : x; } int a[307][307]; inline void work() { ...
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 = [] for row in range(n): grid.append([int(q) if q in '01' else q for q in input()]) changes = [] q = sum([grid[0][2], grid[1][1], grid[2][0]]) if q in (0, 3): if q//3 == grid[0][1]: changes.append([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()) arr = [] for row in range(n): arr.append(input()) n = n+1 if arr[0][1] == arr[1][0] == arr[-2][-1] == arr[-1][-2]: print(2) print(n-2, n-1) print(n-1, n-2) continue elif arr[0][1] == arr[1][0]: if arr[...
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.*; public class B{ static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { ...
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() for i in range(n)] f1=[int(s[0][1]),int(s[1][0])] f2=[int(s[-1][-2]),int(s[-2][-1])] ans=[] if f1==[0,0]: if f2[0]==0: ans.append([n,n-1]) if f2[1]==0: ans.append([n-1,n]) elif f1==[1,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 as _sys ZERO = '0' ONE = '1' def main(): t = int(input()) for i_t in range(t): n, = _read_ints() a = tuple(tuple(_read_line()) for i_row in range(n)) result = tuple(find_cells_to_invert(a)) print(len(result)) for x, y in result: if 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
java
import java.lang.*; import java.io.*; import java.util.*; import java.util.stream.Collectors; public final class Code { public static void main(String[] args) throws Exception{ Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while(t-- > 0) { int n = scanner.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
python2
# Rhythem Jain # Date: 15.09.20 from __future__ import division, print_function import os,sys from io import BytesIO, IOBase from collections import deque, Counter, OrderedDict,defaultdict # from Queue import LifoQueue #from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace #from math import ...
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 i, i1, j, k, k1, t, n, m, res, flag[10], a, b, mt[210][210], f[210]; char x; vector<array<long long, 2>> sl; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { cin >> n; sl.clear(); for (i = 1; i <= n; i++) { for (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
java
import java.io.*; import java.util.*; public class noob { InputReader in; final long mod=1000000007; StringBuilder sb; public static void main(String[] args) throws java.lang.Exception { new noob().run(); } void run() throws Exception { in=new InputReader(System.in); sb =...
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 import math for _ in range(int(input())): n = int(input()) lis=[] for i in range(n): tmp = list(input()) lis.append(tmp) #print(lis[0][1],lis[1][0],lis[n-2][n-1],lis[n-1][n-2]) if lis[0][1]==lis[1][0]: if lis[n-1][n-2]==lis[n-2][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
for _ in range(int(input())): n = int(input()) arr = list() for _ in range(n): arr.append(input()) ss = arr[0][1] sd = arr[1][0] fu = arr[n-2][n-1] fl = arr[n-1][n-2] if ss == sd: if fu == fl: if ss!=fu: print(0) 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; const long long int mod = 1e9 + 7; const long long int inf = 2e9 + 5; double PI = 3.14159265358979323846; void solve() { int n; cin >> n; char c[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> c[i][j]; } } vector<pair<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
java
import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; public class A { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int t = 1; t = sc.nextInt(); while (t-- > 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; const int d4i[4] = {-1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1}; const int d8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1}; template <typename T_n> void read(T_n &n) { cin >> n; } template <typename T_n, typename T_a> void read(T_a a[], T_n 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
java
//package Codeforces; import java.util.*; import java.io.*; public class B { static final int mod = (int) 1e9 + 7; static final int inf = (int) 1e9; static final long INF = (long) 1e18; public static void main(String[] args) { FastScanner fs = new FastScanner(); int T = fs.nextInt(); while (T-- > 0) { 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
import sys input=sys.stdin.readline t=int(input()) def f(mat): c = [["0" for i in range(n)]for j in range(n)] for i in range(n): for j in range(n): c[i][j] = mat[i][j] return c from collections import deque def check(mat,l): for i in range(len(l)): if(mat[l[i][0]][l[i][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
from sys import stdin,stdout from math import gcd,sqrt,factorial,pi,inf from collections import deque,defaultdict input=stdin.readline R=lambda:map(int,input().split()) I=lambda:int(input()) S=lambda:input().rstrip('\n') L=lambda:list(R()) P=lambda x:stdout.write(str(x)+'\n') lcm=lambda x,y:(x*y)//gcd(x,y) hg=lambda x,...
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.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.valueOf(reader.readLine()); while((t--) != 0) { int n = Integer.valu...
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 math import * from bisect import * from collections import * from random import * from decimal import * from itertools import * import sys input=sys.stdin.readline def inp(): return int(input()) def st(): return input().rstrip('\n') def lis(): return list(map(int,input().split())) def ma(): return ...
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 int mod(long long int x) { if (x >= 0) { return x; } return -x; } vector<int> decToBinary(int n) { vector<int> binaryNum(32, 0); int i = 0; while (n > 0) { binaryNum[i] = n % 2; n = n / 2; i++; } return binaryNum; } void solve(vecto...
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 * from functools import * import math import sys # sys.stdin = open("Desktop//ip.txt",'r') # sys.stdout = open("Desktop//op.txt",'w') inp = sys.stdin.readline out = sys.stdout.write def mi(): return map(int,inp().split()) def li(): return list(mi()) def ii(): return int(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
cpp
#include <bits/stdc++.h> using namespace std; bool db = false; const long long INF = 1e18 + 100; const long long MOD = 1e9 + 7; const long long maxn = 2 * 1e6 + 1; long long t, n, m, x, k, q; long long a, b, c, d; pair<long long, long long> pa, pb, pc, pd; long long ans = 0; string s[200]; vector<pair<long long, long l...
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; bool check(vector<vector<int>> &a, int n, int x) { deque<pair<int, int>> q; map<pair<int, int>, bool> was; q.push_back({1, 1}); was[{1, 1}] = true; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; while (!q.empty()) { auto u = q.front(); q.pop_front...
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()) field = [list(input()) for _ in range(n)] s = (int(field[0][1]), int(field[1][0])) f = (int(field[n-1][-2]), int(field[n-2][-1])) ans = 0 coords = [] if len(set(s)) == 1: if s[0] == f[0]: ans += 1 coords....
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 bisect import * from collections import * from math import * from heapq import * from typing import List from itertools import * from operator import * from functools import * #------------------------------------------------------------------------ import os import sys from io import BytesIO, IOBase # region fas...
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.*; public class test { public static void main(String[] args) { int test = fs.nextInt(); // int test = 1; for (int cases = 0; cases < test; cases++) { int n = fs.nextInt(); char ar[][] = new char[n][n]; for (int i = 0; i < n; i++) { String 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
java
import java.util.*; import java.math.*; import java.io.*; import java.lang.*; public class Main { public static void main(String[] args) { FastReader sc = new FastReader(); int t=sc.nextInt(); while(t-- > 0) { int n=sc.nextInt(); String grid[]=new String[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()) ar=[] for i in range(n): ar.append(list(input())) st=[int(ar[0][1]),int(ar[1][0])] fi=[int(ar[n-1][n-2]),int(ar[n-2][n-1])] ans=[] if(st[0]!=st[1] and fi[0]!=fi[1]): if(st[0]!=0): ans.append([1,2]) if(st[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
from sys import stdin,stdout # def valid(x,y): # return 0<=x<n and 0<=y<n # def fn(x,y,dig): # global ans # vis[x][y]=1 # if a[x][y]=='F':return True # for xx,yy in zip([1,-1,0,0],[0,0,1,-1]): # if valid(x+xx,y+yy) and not vis[x+xx][y+yy] and (a[x+xx][y+yy] in ['F',dig]): # # 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
python3
import sys input = sys.stdin.readline for f in range(int(input())): n=int(input()) grid=[] for i in range(n): line=input() line=line[0:n] grid.append(line) if grid[0][1]==grid[1][0]: c=0 cs=[] if grid[-1][-2]==grid[0][1]: c+=1 cs.ap...
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 t = int(input()) for _ in range(t): n = int(input()) grid = [] for i in range(n): grid.append(list(input())) cnt1 = 0 ans1 = [] cnt2 = 0 ans2 = [] for i in range(3): if grid[n-1-i][n-3+i]!='0': cnt1 += 1 ans1.append((n-i,n-2+i)) for i in range(2): if grid[n-1-i][n-2+i]!='1': c...
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(): # put code here n=int(input()) mat=[] for _ in range(n): mat.append(input()) if (mat[0][1] != mat[1][0] and mat[n-2][n-1] != mat[n-1][n-2]): print(2) if mat[0][1]=='0': print(1,2) else: print(2,1) if mat[n-2][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
i = int(input()) for _ in range(i): ii = int(input()) lz = [] for _ in range(ii): lz.append(list(input())) scor = [lz[0][1], lz[1][0]] lcor = [lz[-2][-1], lz[-1][-2]] zer = scor.count('0') zer += lcor.count('0') if zer == 1: print(1) if scor[0] == '0': print('2 1') elif scor[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; const long long int INF = 2e18; const long long int N = 2e5 + 5; bool isPrime(long long int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long int i = 5; i * i <= n; i = i + 6) { if (n % i == 0 || 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> using namespace std; int main() { int t, n, i, j, c; char chr; cin >> t; bool first_diag, second_diag; while (t--) { cin >> n; string arr[n]; vector<int> v; c = 0; for (i = 0; i < n; i++) cin >> arr[i]; first_diag = (arr[0][1] == arr[1][0]); second_diag = (...
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.ArrayList; import java.util.InputMismatchException; import java.util.Locale; import java.util.NoSuchElementException; import java.util.Scanner; import java.util.regex.Pattern; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; public class Solut...
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 = [] for __ in range(n): s.append([int(x) for x in input() if x.isdigit()]) s[0].insert(0,0) s[n-1].insert(n-1,0) c = 0 ans = [] if s[0][1] and s[1][0]: if s[n-1][n-2]: c += 1 ans.append([n,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
cases = int(input()) for c in range(cases): n = int(input()) mat = [] for i in range(n): row = input() mat.append(row) r0c1 = mat[0][1] r1c0 = mat[1][0] rncp = mat[n-1][n-2] rpcn = mat[n-2][n-1] if r0c1 == r1c0: changes = [] if rncp == r0c1: c...
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 input = stdin.readline t = int(input()) for _ in range(t): n = int(input()) a = [list(input().rstrip()) for _ in range(n)] ans = [] if a[0][1] == a[1][0]: if a[-1][-2] == a[0][1]: ans.append((n, n-1)) if a[-2][-1] == a[0][1]: ans.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
cpp
#include <bits/stdc++.h> using namespace std; long long int n; vector<string> a; void input() { a.clear(); cin >> n; for (int i = 0; i < n; i++) { string k; cin >> k; a.push_back(k); } } void solve() { long long int z = 0, o = 0; if (a[0][1] == '0') z++; else o++; if (a[1][0] == '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
java
// package Round676; 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 typeB { public static void main (String[] args) throws java.lang.Exception { Scanner s = new Scanner(System.in); int T = s.nextInt(); for(int t=0;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
cpp
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double pii = 2 * pi; const double eps = 1e-6; const long long MOD = 1e9 + 7; vector<pair<int, int>> del{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; bool dfsf(int n, vector<string>& g) { vector<vector<bool>> v(n, vector<bool>(n, true)); queue<p...
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 maxi = LLONG_MAX; long long mini = LLONG_MIN; void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); } int main() { fast(); long long t; cin >> t; while (t--) { long long n; cin >> n; char a[n][n]; for (long long i = 0; i < n; 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
#Consistency is the key. #code by: amritanshu from sys import stdin,stdout import math from collections import deque input=stdin.readline def print(*args,end='\n'): s=[] for i in args: s.append(str(i)+' ') s=''.join(s) stdout.write(s+end) def solve(): n=int(input()) mat=[] 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
cpp
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e18; const long long minN = -1e18; const int INF = 2e9; const long long MOD = 1e9 + 7; const long long MOD1 = 998244353; const int baseHash = 331; const int bigNumLength = 5000; const long double PI = acos(-1); const long long limit = 2e5 + 5; const ...
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 inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s) ])) def invr(): return(map(int,input().split())) n = inp() for _ in range(n): x = inp() l = [] for j in range(x): l.append(insr()) #print(l) ...
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 = [input() for i in range(n)] a1 = [] a2 = [] if a[0][1]!='0': a1.append([0,1]) if a[1][0]!='0': a1.append([1,0]) if a[n-1][n-2]!='1': a1.append([n-1,n-2]) if a[n-2][n-1]!='1': a1.append([n-2,n-1]) if a[0][1]!='1': a2.append([0,1]) if a[1][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 t, n; char s[207][207]; int main() { cin >> t; while (t--) { cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> s[i][j]; } } int cnt0 = 0, cnt1 = 0; if (s[1][2] == '0') { cnt0++; } 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
java
import java.util.*; public class Putting { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while(t>0) { int n = scanner.nextInt(); char [][] grid = new char [n+1][n+1]; String s; int k = 0; for(int i = 1; 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.util.*; public class Solution_1 { public static void main(String[] args) { // solution start :-) Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); String a[] = new String[n]; for(int i=0;i<n;i++) { a[i] = sc.next(); } String 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
java
import java.io.*; import java.util.*; public class RaifRound { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null |...
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() for i in range(n)] ans = [] if s[0][2] == s[1][1] == s[2][0]: if s[0][1] == s[0][2]: ans += ['1 2'] if s[1][0] == s[0][2]: ans += ['2 1'] 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; char s[205][205]; int main() { long long a, b, t, n, m, i, j; cin >> t; while (t--) { cin >> n; cin.get(); for (i = 0; i <= n; i++) for (j = 0; j <= n; j++) s[i][j] = '0'; for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) cin >> s[i][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
java
import java.util.*; import java.io.*; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new Da...
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(z()) for _ in range(int(z())): x=int(z()) l=list(map(int,z().split())) n=int(z()) l=sorted(list(map(int,z().split())))[::-1] a,b=map(int,z().split()) l=set(map(int,z().split())) led=(6,2,5,5,4,5,6,3,7,6) vowel={'a':0,'e':0,'i':0,'o':0,'u':0} color4=["G", "GB", "YGB", "YGBI", "OYGBI" ,"OY...
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 import sys import collections import bisect #sys.setrecursionlimit(1000000000) input = sys.stdin.readline flush = sys.stdout.flush readint =lambda: int(input()) readintm =lambda: map(int,input().strip().split()) readintl =lambda: list(map(int,input().strip().split())) readfloatm =lambda: map(floa...
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.InputStreamReader; public class B { public static void main(String[] args) throws Exception { BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int t = Integer.parseInt(buffer.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
cpp
#include <bits/stdc++.h> using namespace std; template <class A> void read(vector<A>& v); template <class T> void read(T& x) { cin >> x; } void read(double& d) { string t; read(t); d = stod(t); } void read(long double& d) { string t; read(t); d = stold(t); } template <class H, class... T> void read(H& h, ...
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 import random from typing import List # sys.stdin = open('input.txt', 'r') # sys.stdout = open('output.txt', 'w') input = sys.stdin.readline class Cell: def __init__(self, a, row, col): self.a = a self.row = row self.col = col def value(self): return self.a[self.row][self.col] de...
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.IOException; import java.util.Scanner; public class TestClass { public static void main(String[] args) throws IOException { //BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (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
from sys import stdin, stdout import math,sys,heapq from itertools import permutations, combinations from collections import defaultdict,deque,OrderedDict from os import path import random import bisect as bi def yes():print('YES') def no():print('NO') if (path.exists('input.txt')): #------------------Sublime-----...
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 from sys import stdin, stdout # from fractions import gcd # from math import * # from operator import mul # from functools import reduce # from copy import copy from collections import deque, defaultdict, Counter rstr = lambda: stdin.readline().strip() rstrs = lambda: [str(x) for x in 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
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
python3
t=int(input()) for _ in range(t): n=int(input()) g=[] for i in range(n): g.append(input()) a,b,c,d=g[0][1],g[1][0],g[n-1][n-2],g[n-2][n-1] if a==b and c==d and a!=c: print(0) elif a==b and c!=d: print(1) if c==a: print(n,n-1) elif d==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
python3
for _ in range(int(input())): n = int(input()) arr = [list(input()) for i in range(n)] t = [] s = [arr[0][1],arr[1][0]] f = [arr[-1][-2],arr[-2][-1]] if f[0]==f[1]: if f[0]=='0': if s[0]=='0': t.append([1,2]) if s[1]=='0': t.append([2,1]) else: if s[0]=='1': t.append([1,2]) if s[1]=='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 re import sys exit=sys.exit from bisect import bisect_left as bsl,bisect_right as bsr from collections import Counter,defaultdict as ddict,deque from functools import lru_cache cache=lru_cache(None) from heapq import * from itertools import * from math import inf from pprint import pprint as pp enum=enumerate ri...