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
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
python3
for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) l=0;l1=1;l2=2 t=0 while l2<n: #print(a[l]+a[l1],a[l2]) if a[l]+a[l1]>a[l2]: l+=1;l1+=1;l2+=1 else: print(l+1,l1+1,l2+1) t=1 break if t==0: ...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long const MOD = 1e9 + 7; int const max_n = 1e5 + 20; void yes(string a = "YES") { cout << a << '\n'; } void no(string a = "NO") { cout << a << '\n'; } long long fact(int n) { long long ans = 1; for (int i = 2; i <= n; i++) { ans = (ans * i) % MOD; } return...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, x, i, j, k, temp, m; cin >> n; std::vector<long long int> a(n); for (auto &it : a) cin >> it; for (i = 1; i < n - 1; ++i) { if (a[i] + a[i - 1] < a[i + 1]) { cout << i << " " << i + 1 << " " << i + 2 << endl; return;...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
python3
t=int(input()) for i in range(t): n=int(input()) arr=[int(item) for item in input().split()] if(arr[0]+arr[1]<=arr[-1]): print(0,1,n-1) else: print(-1)
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
java
import java.util.Scanner; public class BadTriangle { public static void main(String args[]) { Scanner in= new Scanner(System.in); int t = in.nextInt(); int i; int[] res=new int[3*t]; for(i=0;i<t;i++) { int n = in.nextInt(); int[] ar = new int[n]; int j; for(j=0;j<n;j++) ar[j]=in.next...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> void pr(vector<T> &v) { for (int i = 0; i < (int)(v).size(); i++) cout << v[i] << " "; cout << endl; } template <typename T> void pr(vector<vector<T>> &v) { for (int i = 0; i < (int)(v).size(); i++) { pr(v[i]); } } template <typename T> voi...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
java
import java.util.Scanner; public class BadTraingle { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t =sc.nextInt(); while(t-->0) { int n = sc.nextInt(); long arr[] = new long[n]; for(int i=0 ; i<n ; i++) ...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
python3
import sys import random from fractions import Fraction from math import * def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def finput(): return float(input()) def tinput(): return input().split() def linput(): return list(input()) def rinput(): return ...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long lo...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
python3
a = int(input()) s = [] for i in range(a): b = int(input()) c = input().split(' ') if int(c[0])+int(c[1]) <= int(c[b-1]): s.append('1') s.append('2') s.append('{}'.format(b)) else: s.append('-1') for j in range(len(s)-2): if s[j] == '-1': print(-1) elif s[...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package coding; import java.util.Arrays; import java.util.Scanner; /** * * @author DELL */ public class Coding { /** *...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t = 1; cin >> t; while (t--) { long long int n, a, b, c, p = 0; cin >> n; long long int A[n], i; for (i = 0; i < n; i++) cin >> A[i]; for (i = 0; i < ...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
python3
import sys read = lambda: sys.stdin.readline().strip() def isDegenerate(a, b, c): if a + b <= c: # or b + c <= a or a + c <= b: return True return False for _ in range(int(read())): length = int(read()) nums = list(map(int, read().split())) end = length - 1 start = 0 mid = (start ...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
python3
for _ in range(int(input())): n = int(input()) b = list(map(int,input().split())) a = list(set(b)) l = len(a) if len(a)==1: print("-1") quit() elif len(a)==2: x = b.count(a[0]) y = b.count(a[1]) if x>y and 2*a[0]>a[1]: print("-1") else:...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package codechefc; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOE...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
java
import java.util.*; public class BadTriangle { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc= new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int c=0,n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) a[i]=sc.nextInt(); for(int i=0;i<...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, counter = 1, ans = 0; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) { cin >> arr[i]; if (i && arr[i - 1] == arr[i]) counter++; else if (i) { ans = max(ans,...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int i; int n; cin >> n; int sides[1000000]; int flag = 0; for (int i = 0; i < n; i++) { cin >> sides[i]; } for (i = 2; i < n; i++) { if (sides[i] >= (sides[i - 1] + sides[i - 2])) ...
1398_A. Bad Triangle
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i ≀ a_{i + 1}). Find three indices i, j, k such that 1 ≀ i < j < k ≀ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to...
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n" ], "output": [ "1 2 7\n-1\n1 2 3\n" ] }
{ "input": [ "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "1\n6\n1 1 1 2 2 3\n", "1\n3\n21 78868 80000\n", "1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n", "1\n3\n78788 78788 157577\n", "1\n3\n5623 5624 10000000\n", "1\n10\n1 7 7 7 7 9 9 9 9 9\n", "1\n3\n5739271 5739272 2000...
IN-CORRECT
java
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { FastReader sc =new FastReader(); int t=sc.nextInt(); // int t=1; while(t-->0) { int n=sc.nextInt(); long arr[] = sc...
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
l=[] for _ in range(int(input())): n=int(input()) a=[] for i in range(n): a.append(list(input())) if a[0][1]==a[1][0]: if a[n-1][n-2]==a[n-2][n-1]: if a[n-1][n-2]==a[0][1]: l.append("2") l.append("1 2") l.append("2 1") ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import javax.swing.tree.TreeNode; import java.io.IOException; import java.io.InputStream; import java.util.*; public class TestClass { static final class InputReader { private final InputStream stream; private final byte[] buf = new byte[1024]; private int curChar; private int 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
// No sorcery shall prevail. // import java.util.*; import java.io.*; public class InVoker { //Variables static long mod = 1000000007; static long mod2 = 998244353; static FastReader inp= new FastReader(); static PrintWriter out= new PrintWriter(System.out); public static void main(String args[]) { ...
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.reflect.Array; import java.util.*; public class Solution { public static boolean check(String x,String y,String[][] s){ int n=s.length-1; int a=s[0][1].equals(y)?1:0; int b=s[1][0].equals(y)?1:0; int c=s[n][n-1].equals(x)?1:0; int d=s[n-1][n].equals(x)?1:0; ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) for i in range(t): n=int(input()) l=[] for i in range(n): l.append(list(input())) if l[0][1]=='0' and l[1][0]=='0': if l[n-2][n-1]=='0' and l[n-1][n-2]=='0': print(2) print(n-1,n) print(n,n-1) elif l[n-2][n-1]=='0' and l[n-1][n-2...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n = int(input());grid = [input() for i in range(n)];a, b, c, d = grid[0][1], grid[1][0], grid[-2][-1], grid[-1][-2];e = []; f = [] if a != '0':e.append((1, 2)) if b != '0':e.append((2, 1)) if c != '1':e.append((n-1, n)) if d != '1':e.append((n, n-1)) if c != '0':f.append((n-1,n)) if...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for tt in range(int(input())): n = int(input()) g = [input() for i in range(n)] for i in range(2): m = [] if g[0][1] != str(i) : m.append((0,1)) if g[1][0] != str(i) : m.append((1,0)) if g[n-1][-2] != str(i^1) : m.append((n-1,n-2)) if g[-2][n-1] != str(i^1) : m.appen...
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 i in range(n): temp=list(str(input())) arr.append(temp) change=[] #print(arr) if arr[0][1]==arr[1][0]: if arr[0][1]=="1": if arr[n-2][n-1]!="0": change.append([n-1,n]) ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int inf = INT_MAX; const long long int inf64 = LLONG_MAX; vector<string> vect; long long int n; vector<pair<int, int> > d4{{-1, 0}, {1, 0}, {0, 1}, {0, -1}}; bool good(long long int xx, long long int yy) { return (xx < n and xx >= 0 and yy < n and yy >= 0); } int 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
python3
t = int(input()) for i in range(t): list1 = [] n = int(input()) for j in range(n): list1.append(input()) s_right = list1[0][1] s_down = list1[1][0] f_left = list1[-1][-2] f_up = list1[-2][-1] if s_right==s_down and f_left==f_up: if s_right!=f_left: 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
python3
def main(): for _ in range(int(input())): n=int(input()) a=[] for i in range(n): a.append(input()) ans=[] if a[0][1]==a[1][0]: if a[n-1][n-2]==a[0][1]: ans.append((n,n-1)) if a[n-2][n-1]==a[0][1]: an...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
test_case_num = int(input()) for i in range(test_case_num): a = int(input()) list = [] for k in range(a): list.append(input()) x= list[0][1] y= list[1][0] z = list[a-1][a-2] p = list[a-2][a-1] if x=='0' and y=='0' and z=='0' and p=='1': #0001 print(1) print(a, 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
java
import java.io.*; import java.util.*; public class Main { InputStream is; PrintWriter out; String INPUT = ""; void solve(int TC) throws Exception { int n = ni(); char[][] s = new char[n][n]; for(int i=0;i<n;i++) s[i] = ns(n); //bfs.. int a1 = s[0][1]-'0'; int a2 = s[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 sa(): return map(int,input().split()) def ra(): return list(map(int,input().split())) def mati(n): return [ra() for i in range(n)] def ri(): return int(input()) for _ in range(ri()): n=ri() g = [input() for i in range(n)] if g[0][1]==g[1][0]==g[-2][-1]==g[-1][-2]: print('2\n1 2\n2 1') elif g...
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() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; char a[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; } } if (a[1][0] == a[0][1] && a[n - 1][n - 2] == a[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 Tc, N; char Grid[205][205]; int main() { cin >> Tc; while (Tc--) { cin >> N; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) cin >> Grid[i][j]; } if (Grid[1][2] == Grid[2][1]) { if (Grid[N - 1][N] == Grid[N][N - 1] && Grid[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
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Prac{ static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; public InputReader(InputStream st) { ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) for you in range(t): n=int(input()) l=[] for i in range(n): s=input() l.append(s) if(l[0][1]==l[1][0]): z=l[0][1] lo=[] if(l[-1][-2]==z): lo.append((n,n-1)) if(l[-2][-1]==z): lo.append((n-1,n)) print(len(lo)) ...
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 * t=int(input()) while t: t=t-1 #a,b=map(int,input().split()) n=int(input()) #a=list(map(int,input().split())) #out=a^b #out2=a^b+b^b #print(out) a=[] for i in range(n): s=input() a.append(s) l=[a[0][1],a[1][0],a[n-1][n-2],a[n-2][n-1]] oc...
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.LinkedList; import java.util.Scanner; public class B1421 { private StreamTokenizer in; private PrintWriter out; Scanner sc; public int nextInt() throws IOException { return sc.nextInt(); } public String nextString() throws IOException { 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
python3
from collections import defaultdict t = int(input()) for _ in range(t): n = int(input()) grid = [] for i in range(n): grid.append([i for i in input()]) if grid[0][1] == grid[1][0]: ans = [] if grid[0][1] == '0': if grid[n-1][n-2] == '0': ans.append([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 " "*int(input()): n=int(input()) lst=[] for i in range(n): s=list(input()) lst.append(s) if lst[1][0] == "0" and lst[0][1] == "1" and lst[n-2][n-1]=="0" and lst[n-1][n-2]=="1": print(2) print(2,1) print(n,n-1) elif lst[1][0] == "1" and lst[0][1] == "0" and lst[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
cpp
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 9; set<int> ist; map<string, int> msi; map<string, string> mss; map<int, string> mis; map<int, int> mii; pair<int, int> pii; vector<int> v; vector<pair<int, int> > vv; int cc[] = {1, -1, 0, 0}; int rr[] = {0, 0, 1, -1}; void SUNRISE() { int t; cin ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.util.*; public class test{ public static void main(String[] args) { // TODO Auto-generated method stub @SuppressWarnings("resource") Scanner sc=new Scanner(System.in); int t=0; t=sc.nextInt(); while(t>0) { t--; int n=sc.nextInt(); int a=-1,b=-1,c=-1,d=-1; String arr[]=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
t = int(input()) for j in range(t): n = int(input()) a = [] for i in range(n): temp = str(input()) a.append([str(x) for x in temp]) #print(a) count = 0 ans= [[a[0][1],1,2],[a[1][0],2,1],[a[0][2],1,3],[a[1][1],2,2],[a[2][0],3,1]] #print(ans) check1 = ['1','1','0','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
python3
""" https://codeforces.com/contest/1421/problem/B """ for _ in range(int(input())): n = int(input()) array = [] for _ in range(n): array.append(list(input())) important = [] important.append(int(array[0][1])) important.append(int(array[1][0])) important.append(int(array[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
java
import java.io.*; import java.util.*; public class Main { static final boolean INPUT_FROM_FILE = false; static final String INPUT_FILE = "input/input.txt"; static final String OUTPUT_FILE = "input/output.txt"; static FastReader in; static FastWriter out; static { try { in = new FastReader(); out = ne...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long i, j, m, n, k; long long t; cin >> t; while (t--) { cin >> n; char a[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { cin >> a[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
python3
""" Author - Satwik Tiwari . 18th Oct , 2020 - Sunday """ #=============================================================================================== #importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from io import Byte...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t = int(input()) while t!=0: n = int(input()) list1 = [] for i in range(n): temp = list(input()) list1.append(temp) s1 = list1[0][1] s2 = list1[1][0] l1 = list1[-2][-1] l2 = list1[-1][-2] ans = [] if s1==s2: if s1=="0": if l1=="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 N = 204; int t, n; string s[N]; void solve(char z1, char z2, char y1, char y2) { if (z1 == '0' && z2 == '0') { if (y1 == '1' && y2 == '1') puts("0"); else if (y1 == '0' && y2 == '0') { printf("2\n%d %d\n%d %d\n", n, n - 1, n - 1, n); } el...
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()) arr = [] for i in range(n): arr += [input()] a, b = int(arr[0][1]), int(arr[1][0]) x, y = int(arr[-1][-2]), int(arr[-2][-1]) ans = [] if x == 0 and y == 0: if a == 0: ans += [[1, 2]] if b == 0: ans += [[2, 1]] elif x == 1 and y == 1: if 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
def solve(): n = int(input()) grid = [] for i in range(0,n): grid.append([x for x in input()]) a = grid[0][1] b = grid[1][0] c = grid[n-1][n-2] d = grid[n-2][n-1] changes = [] change = 0 if a==b: if c==a: change+=1 changes.append((n,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
from sys import stdin input = stdin.readline def solve(): n = int(input()) s = [''] * n for i in range(n): s[i] = input().strip() s1 = int(s[0][1]) s2 = int(s[1][0]) e1 = int(s[-1][-2]) e2 = int(s[-2][-1]) res = 0 r = [] if s1 == s2: if e1 == s1: re...
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
if __name__ == '__main__': t = int(input()) for i in range(t): n = int(input()) matrix = [input() for j in range(n)] # (1,2) (2,1) (n,n-1) (n-1,n) val = matrix[0][1] + matrix[1][0] + matrix[n-1][n-2] + matrix[n-2][n-1] answer = { '0000' : [(1,2),(2,1)], '0001' :...
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
''' =============================== -- @uthor : Kaleab Asfaw -- Handle : kaleabasfaw2010 -- Bio : High-School Student ===============================''' # Fast IO import sys import os from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(sel...
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
rn=lambda:int(input()) rl=lambda:list(map(int,input().split())) rns=lambda:map(int,input().split()) rs=lambda:input() yn=lambda x:print('Yes') if x else print('No') YN=lambda x:print('YES') if x else print('NO') for _ in range(rn()): n=rn() l=[] for i in range(n): l.append(input()) if l[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.*; import java.math.BigInteger; import java.util.*; import java.util.List; import java.awt.*; public class Main { static long sx = 0, sy = 0, mod = (long) (1e9 + 7); static int[][] dirs = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 }, { 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1 } }; static ArrayList<Int...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) for _ in range(t): n=int(input()) grid=[] for i in range(n): grid.append(list(input())) #print(grid) top1=grid[0][1] top2=grid[1][0] down1=grid[n-2][n-1] down2=grid[n-1][n-2] if(top1=='0' and top2=='0'): if(down1=='0' and down2=='0'): ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import sys input=sys.stdin.readline from collections import defaultdict as dc from bisect import bisect_right import math for _ in range(int(input())): n=int(input()) l=[] for i in range(n): l.append(list(input())) a,b,x,y=l[0][1],l[1][0],l[n-1][n-2],l[n-2][n-1] if a=='1' and b=='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
# Author: S Mahesh Raju # Username: maheshraju2020 # Created on: 22/10/2020 00:46:10 from sys import stdin, stdout, setrecursionlimit import heapq from math import gcd, ceil, sqrt from collections import Counter, deque from bisect import bisect_left, bisect_right from itertools import combinations, permutations ii1 = ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
test = int(input()) for _ in range(test): n = int(input()) mat = [] for i in range(n): mat.append(list(input())) a = int(mat[-1][-2]) b = int(mat[-2][-1]) c = int(mat[0][1]) d = int(mat[1][0]) ans = [] if a==b: ans = [] if c==a: ans.appen...
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 power(long long x, long long n, long long mod) { long long res = 1; x %= mod; while (n) { if (n & 1) res = (res * x) % mod; x = (x * x) % mod; n >>= 1; } return res; } signed main() { ios::sync_with_stdio(0); cin.tie(0); long long c = 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 myXOR(long long int x, long long int y) { return (x | y) & (~x | ~y); } int main() { int tt = 1; cin >> tt; while (tt--) { long long int n, i, j; cin >> n; char a[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) cin >> a[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
python3
cases = int(input()) for t in range(cases): n = int(input()) s = [] for i in range(n): s.append(list(input())) l = [int(s[-1][-3]),int(s[-1][-2]),int(s[-2][-2]),int(s[-2][-1]),int(s[-3][-1])] l1 = [1,0,1,0,1] l2 = [0,1,0,1,0] o1 = [l1[i]!=l[i] for i in range(5)] o2 = [l2[i] != 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()) d = {} for i in range(n): o = input() for j in range(n): x = o[j] d[(i+1,j+1)] = x if d[(1,2)] == d[(2,1)] == d[(n,n-1)] == d[(n-1,n)]: print(2) print(1,2) print(2,1) continue 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.*; public class Main { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(System.in); PrintWriter pw = new PrintWriter(System.out); StringBuilder sb0 = new StringBuilder(); StringBuilder sb1 = new StringBuil...
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 minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): n = mint() a = [None]*n for i in range(n): a[i] = minp() c = [None,None,None,None] pos = [(0,1,0),(1,0,1),(2,n-1,n-2),(3,n-2,n-1)] #print(a) for i,x,y in po...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
T = int(input()) for t in range(T): N = int(input()) M = [] for i in range(N): M.append(input()) inverts = [] if M[0][1] == '0' and M[1][0] == '0': if M[N-2][N-1] == '0': inverts.append((N-2, N-1)) if M[N-1][N-2] == '0': inverts.append((N-1, N-2)) ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
def solv(): x = int(input()) s = [list(input()) for n in range(x)] ct = 0 v = [] if s[0][1] != '0': ct += 1 v.append([1, 2]) if s[1][0] != '0': ct += 1 v.append([2, 1]) if s[x-1][x-2] != '1': ct += 1 v.append([x, x-1]) if s[x-2][x-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
# -*- coding: utf-8 -*- """ Created on Sat Oct 24 11:08:45 2020 @author: alber """ def pink(matrix,n): counter = 0 final1 = matrix[n-1][n-2] final2 = matrix[n-2][n-1] entrada1 = matrix[0][1] entrada2 = matrix[1][0] if final1 == final2: if entrada1 == final1...
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()) mat=[] c=0 for i in range(n): mat.append(list(input())) out=[] if mat[1][0]==mat[0][1]: par=int(mat[1][0])^1 if mat[-1][-2]!=str(par): c+=1 out.append((n,n-1)) if mat[-2][-1]!=str(par): ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
java
import java.io.*; import java.util.*; import static java.lang.Integer.*; public class B { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = in.nextInt(); for (int t1 = 0; t1 < t; 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
for ii in range(int(input())): n=int(input()) a,c,ans=[],0,"" for jj in range(n): a.append(input()) sr,sd,eu,el=a[0][1],a[1][0],a[n-2][n-1],a[n-1][n-2] if sr == sd: if el == sr: c += 1 ans += str(n) + " " + str(n - 1) + "\n" if eu == sr: 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
t = int(input()) for ti in range(t): n = int(input()) grid = [] for tn in range(n): grid.append(input()) bord = [ grid[1][0], grid[0][1], grid[n-1][n-2], grid[n-2][n - 1] ] ans = [] for ls in [ [ '0', '0' , '1' , '1'], ['1', '1', '0', '0' ]]: ans = [] for i in range(4)...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n = int(input()) l = [] for i in range(n): a = input() l.append(a) ans = [] if l[0][1]==l[1][0]: if l[0][1]=='1': if l[n-2][n-1]=='1': ans.append([n-1,n]) if l[n-1][n-2]=='1': ans.append([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
t = int(input()) for _ in range(t): n = int(input()) a = [] for i in range(n): a.append(list(input())) #print(a) if ((a[0][1] == a[1][0]) and (a[n-1][n-2] == a[n-2][n-1])): if (a[0][1] == a[n-1][n-2]): print(2) print("{} {}".format(n,n-1)) 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
python3
import math t = int(input()) for _ in range(t): n = int(input()) s = [] for i in range(n): a = input() s.append(list(a)) if s[0][1]==s[1][0]: if s[-1][-2]==s[-2][-1]: if s[-1][-2]==s[0][1]: print(2) print(n-1,n) pri...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s; int n; cin >> n; getline(cin, s); vector<vector<char>> v(n); char c; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> c; v[i].push_back(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
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5, mod = 1e9 + 7, len = 30; void run_case() { 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, int>> vec; if (c[0][1] == c[1][0]) { if (c[n - 1][n - 2] == c[0][1])...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
t=int(input()) for j in range(t): ans = [] n=int(input()) li = [] for i in range(n): s=input() k=len(s) li.append(s) if li[0][1] == li[1][0]: if li[k-2][n-1] == li[k-1][n-2]: if li[0][1] == li[k-2][n-1]: r = [] r.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
t = int(input()) for _ in range(t): a = int(input()) lis = [] for j in range(a): if j == 0: sh = list(input()) sh[0] = "7" sh = list(map(int, sh)) elif j == a-1: sh = list(input()) sh[-1] = "7" sh = list(map(int, sh)) ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n=int(input()) a=[] for i in range(n): s=input() t=[] for j in s: t.append(j) a.append(t) if a[0][1]==a[1][0]: if a[n-1][n-2]==a[n-2][n-1]: if a[n-1][n-2]==a[0][1]: print(2) 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
#import modules here import math,sys,os #from itertools import permutations, combinations from collections import defaultdict,deque,OrderedDict,Counter import bisect as bi #import heapq from io import BytesIO, IOBase mod=10**9+7 # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(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
def testcase(): n = int(input()) grid = [] for _ in range(n): grid.append(input()) s1, s2 = grid[0][1], grid[1][0] f1, f2 = grid[-1][-2], grid[-2][-1] if s1 == s2: if f1 == f2: if s1 == f1: print(2) print(1, 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
java
import java.util.*; public class b{ public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); while(t-->0){ int n = s.nextInt(); String arr[] = new String[n]; for(int i=0;i<n;i++){ arr[i] = s.next(); } char ch1 = arr[0].charAt(1); char ch2 = arr[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
for _ in range(int(input())): n = int(input()) arr= [] for i in range(n): arr.append(input()) s1 = arr[0][1] s2 = arr[1][0] e1 = arr[n-2][n-1] e2 = arr[n-1][n-2] ans = [] if(s1==s2): if(e1==s1): ans.append((n-2,n-1)) if(e2==s1): ans.app...
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; mt19937 rnd(1337); ostream& operator<<(ostream& a, const pair<long long, long long> b) { cout << "{" << b.first << ", " << b.second << "}"; return a; } ostream& operator<<(ostream& a, const vector<long long int>& b) { for (auto& k : b) cout << k << " "; return 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
# coding=utf-8 # Created by TheMisfits from sys import stdin _input = stdin.readline _range, _list, _str, _int = range, list, str, int def solution(): for _ in _range(_int(_input())): n = _int(_input()) arr = [] for i in _range(n): arr.append(_list(_input().rstrip('\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
t=int(input()) while(t): t=t-1 n=int(input()) for i in range(n): s=input() if(i==0): ur=s[1] if(i==1): ud=s[0] if(i==n-2): du=s[-1] if(i==n-1): dl=s[-2] if(ur=='1' and ud=='1'): if(du=='0' and dl=='0'): ...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
import math import sys,bisect from heapq import * from itertools import * from collections import * sys.setrecursionlimit(10 ** 6) I = lambda : int(sys.stdin.readline()) neo = lambda : map(int, sys.stdin.readline().split()) Neo = lambda : list(map(int, sys.stdin.readline().split())) for _ in range(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
import sys input = sys.stdin.readline def main(): n = int(input()) maze = [input().strip() for _ in range(n)] ans = [] if maze[0][1] == "0": ans.append((1, 2)) if maze[1][0] == "0": ans.append((2, 1)) if maze[n - 1][n - 2] == "1": ans.append((n, n - 1)) if maze[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> #pragma GCC optimize("unroll-loops") #pragma GCC optimize("Ofast", "no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } long long int exp(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; void testCase() { long long n; cin >> n; vector<string> grid(n); vector<pair<long long, long long>> ans; for (string &s : grid) cin >> s; char t1 = grid[0][1]; char t2 = grid[1][0]; char b1 = grid[n - 1][n - 2]; char b2 = grid[n - 2][n - 1]; if (t1 == t2...
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 j in range(int(input())): n=int(input()) a=[list(input()) for i in range(n)] t=a[0][1] r=a[1][0] w=a[-1][-2] y=a[-2][-1] d=[] if t==r=='1': if w=='1': d.append([n,n-1]) if y=='1': d.append([n-1,n]) elif t==r=='0': if w=='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
for _ in range(int(input())): n=int(input()) l=[] for i in range(n): s=str(input()) l.append(s) a=int(l[0][1]) b=int(l[1][0]) c=int(l[n-1][n-2]) d=int(l[n-2][n-1]) if(a==0 and b==0): if(c==1 and d==1): print(0) elif(c==1 and d==0): print(1) print(n-1,n) elif(c==0 and d==1): print(1) pri...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): ls =[] n = int(input()) for i in range(n): ls.append(input()) a = ls[0][1]; b = ls[1][0]; c = ls[n-2][n-1]; d= ls[n-1][n-2] ans =[] f=1 if a==b : if a==c: ans.append([n-1 , n]) if a==d: ans.append([n, 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
# =============================================================================================== # importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from io import BytesIO, IOBase from itertools import * import bisect from heapq 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
python3
import sys t = int(sys.stdin.readline()) for _ in range(t): n = int(sys.stdin.readline()) A = [] for _ in range(n): A.append(sys.stdin.readline().strip()) a = A[0][1] b = A[1][0] c = A[-1][-2] d = A[-2][-1] cells = [] if a == b: if c == a: cells.append...
1421_B. Putting Bricks in the Wall
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like [walls](https://www.youtube.com/watch?v=YR5ApYxkU-U), he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid. Roger Waters has a square grid of size nΓ— n and he wants to traverse his grid f...
{ "input": [ "3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F\n" ], "output": [ "1\n3 4\n2\n1 2\n2 1\n0\n" ] }
{ "input": [ "1\n3\nS01\n111\n00F\n", "1\n5\nS0000\n00000\n00000\n00000\n0000F\n", "1\n3\nS10\n010\n11F\n", "1\n3\nS11\n011\n01F\n", "1\n3\nS10\n010\n01F\n", "1\n10\nS000000000\n0000000000\n0000000000\n0000000000\n0000001000\n0000000101\n0000000000\n0000000000\n0000000000\n000000000F\n" ], ...
CORRECT
python3
for _ in range(int(input())): n = int(input()) grid = [] count = 0 ans = [] for i in range(n): grid.append(list(input())) if grid[0][1]=='0' and grid[1][0]=='0': if grid[n-2][n-1]!='1': count += 1 ans.append([n-1,n]) if grid[n-1][n-2]!='1': ...