solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
for _ in range(int(input())): n = int(input()) l =list(map(int , input().split())) a,b,c = l[0] , l[1] , l[-1] if a+b>c and a+c>b and b+c>a: print(-1) else: print(1,2 , n, sep=' ')
7
PYTHON3
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) if(a[0]+a[1] <= a[-1]): print(1, 2, n) else: print("-1")
7
PYTHON3
for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) a1 = a[0] a2 = a[1] a3 = a[-1] if (a1 + a2 <= a3): print(1, 2, len(a)) else: print(-1)
7
PYTHON3
for t in range(int(input())): n = input() a = [int(_) for _ in input().split()] if a[0]+a[1] <= a[-1]: print(1,2,n) else: print(-1)
7
PYTHON3
for _ in range(int(input())): n=int(input()) arr=list(int(i) for i in input().split()) mn1=arr[0] mn2=arr[1] mx1=arr[-1] if mn1+mn2>mx1: print(-1) else: print(1,2,n)
7
PYTHON3
# -*- coding: utf-8 -*- """Untitled109.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1X8-VINDMTMre7Qt2DyQiUJHJz7Qf9Y8v """ for _ in range(int(input())): n=int(input()) l=[int(x) for x in input().split()] if l[0]+l[1]<=l[-1]: print(1,2...
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long Bin_expo(long long n, long long b, long long m) { long long res = 1; while (b > 0) { if (b & 1) { res = (res * n) % m; } n = (n * n) % m; b /= 2; } return res % m; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cou...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int t, n, arr[50005]; cin >> t; for (int i = 0; i < t; i++) { int x = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } if (arr[0] + arr[1] <= arr[n - 1]) { cout << "1" << " " << "2" ...
7
CPP
for test in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = a[0] c = a[1] d = a[-1] if c + b > d: print(-1) else: print(1, 2, n)
7
PYTHON3
def checkinvalidity(a, b, c): if (a + b <= c) or (a + c <= b) or (b + c <= a) : return True else: return False for _ in range(int(input())): count=0 n= int(input()) arr= list(map(int,input().split())) for i in range(n-2): a=arr[i] b=arr[i+1] c=arr...
7
PYTHON3
t=int(input()) for _ in range(t): n=int(input()) a=list(map(lambda x: int(x), input().split())) minimum=a[0] minimum_index=0 for i in range(1,len(a)): if a[i]<minimum: minimum=a[i] minimum_index=i second_minimum=a[0] if 0!=minimum_index else a[1] second_minimu...
7
PYTHON3
for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) f=0 b=a[0] c=a[1] for i in range(n-1,-1,-1): if(b+c<=a[i]): print("1",end=' ') print("2",end=' ') print(i+1) f=0 break else: f=1 ...
7
PYTHON3
for _ in range(int(input())): n = int(input()) s = [*map(int,input().split())] if s[0] + s[1] <= s[-1]: print(1,2,n) else: print(-1)
7
PYTHON3
t=int(input()) for _ in range(t): n=int(input()) k=0 l=list(map(int,input().split(" "))) s=l[0]+l[1] for a in range(2,n): if s<=l[a]: print(""+str(1)+" "+str(2)+" "+str(a+1)) k=-1 break if k!=-1: print("-1")
7
PYTHON3
t = int(input()) for _ in range(t): n = int(input()) l = list([int(x) for x in input().split()]) a = l[0] b = l[1] c = l[n-1] if(a+b <= c): print(1, 2, n) else: print('-1')
7
PYTHON3
from sys import stdin, stdout input = stdin.readline #print = stdout.write for _ in range(int(input())): n = int(input()) a = list(map(int,input().split())) b = [(a[i],i+1) for i in range(len(a))] b.sort(key = lambda x: x[0]) if b[0][0]+b[1][0]<=b[-1][0]: t = b[0][1],b[1][1], b[-1][1] ...
7
PYTHON3
# -*- coding: utf-8 -*- """ t=int(input()) for _ in range(t): n=int(input()) x=list(map(int,input().split())) k,m=map(int,input().split()) s=input() @author: krishna """ t=int(input()) for _ in range(t): n=int(input()) x=list(map(int,input().split())) f=0 l=x[-1] for i in range(n-1...
7
PYTHON3
t=int(input("")) for i in range(t): la=int(input("")) l=[0,1] a=[int(x) for x in input("").split()] ai=a[0] aj=a[1] for i in range(2,la): if ai+aj<=a[i]: l.append(a.index(a[i])) for k in l: print(k+1,end=' ') print() break ...
7
PYTHON3
numOfCases = int(input()) numOfElements = 0 for i in range(numOfCases): numOfElements = int(input()) lengthInputs = input() lengthInputs = lengthInputs.split(" ") lengthInputs = [int(x) for x in lengthInputs] if (lengthInputs[-1] >= (lengthInputs[0] + lengthInputs[1])): print("1 2", str(numO...
7
PYTHON3
for i in range(int(input())): n = int(input()) a = [int(i) for i in input().split()][:n] s = a[0] + a[1] if s > a[-1]: print(-1) else: print(1,2,n)
7
PYTHON3
import os #2 inp=os.read(0,os.fstat(0).st_size).split(b"\n");_ii=-1 def rdln(): global _ii _ii+=1 return inp[_ii] inin=lambda typ=int: typ(rdln()) inar=lambda typ=int: [typ(x) for x in rdln().split()] inst=lambda: rdln().strip().decode() _T_=inin() for _t_ in range(_T_): n=inin() a=inar() if a[0...
7
PYTHON3
T=int(input()) for z in range(T): N=int(input()) a=[int(x) for x in input().split()] if a[0]+a[1]<=a[len(a)-1]: print(1," ",2," ",len(a)) else: print(-1)
7
PYTHON3
for _ in range(int(input())): n=int(input()) l=[int(x) for x in input().split()] if l[0]+l[1]>l[-1]: print(-1) else: print(1,2,n)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll t; cin >> t; while (t--) { ll n; cin >> n; vector<ll> sides(n); for (int i = 0; i < (n); ++i) cin >> sides[i]; if (sides[1] > (sides[n - 1] - sides[0])) ...
7
CPP
t = int(input()) ans = [] def solve(n,arr): Max = arr[-1] for l in range(n-2): if arr[l]+arr[l+1]<=Max: answer = [l+1,l+2,n] return answer return [-1] for i in range(t): n = int(input()) arr = [int(x) for x in input().split()] ans.append(solve(n,arr)) for test ...
7
PYTHON3
t=int(input()) for i in range(t): n=int(input()) k=list(map(int,input().split())) a,b,c=0,1,n-1 if((k[a]+k[b])>k[c]): print(-1) else: print(a+1,b+1,c+1)
7
PYTHON3
t = int(input()) nLst = [] triLst = [] for tt in range(t): n_i = int(input()) nLst.append(n_i) tri = input().split() for x in range(len(tri)): tri[x] = int(tri[x]) triLst.append(tri) for i in range(t): for j in range(2, len(triLst[i])): if (triLst[i][0] + triLst[i][1] <= triLs...
7
PYTHON3
import math,sys from sys import stdin,stdout from collections import Counter, defaultdict, deque input = stdin.readline I = lambda:int(input()) li = lambda:list(map(int,input().split())) def solve(): n=I() a=li() p,q,r=a[0],a[1],a[-1] if(p+q<=r): print(1,2,n) else: print(-1) for _ i...
7
PYTHON3
for i in " "*int(input()): n=int(input()) a=list(map(int,input().split()))[:n] if a[0]+a[1]>a[-1]: print(-1) else: print(1,2,n)
7
PYTHON3
from sys import * def resolve(t): N = int(stdin.readline().rstrip()) array = [int(x) for x in stdin.readline().rstrip().split()] #dk: c < a + b , c lon nhat a = array[0] b = array[1] c = array[N-1] if (c >= a + b): print(str(1) + " " + str(2) + " " + str(N)) return pr...
7
PYTHON3
import sys import math from collections import Counter,defaultdict input = sys.stdin.readline LI=lambda:list(map(int,input().split())) MAP=lambda:map(int,input().split()) IN=lambda:int(input()) S=lambda:input() def case(): n=IN() a=LI() if a[0]+a[1]>a[-1]: print(-1) else: print(1,2,n) ...
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int a, b, c; cin >> a; cin >> b; for (int i = 0; i < n - 2; i++) { cin >> c; } if (a + b <= c) { cout << "1 2 " << n << endl; } else { cout << -1 << endl...
7
CPP
for _ in range(int(input())): n = int(input()) A = list(map(int,input().split())) if not A[n-1]>= A[0]+A[1]: print(-1) else: print(1,2,n)
7
PYTHON3
t=int(input()) for i in range(t): n=int(input()) l=list(map(int,input().split())) if l[0]+l[1]>l[n-1]: print(-1) else: print(1,2,n)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b = 0, c = 0, d = 0, e = 0; cin >> a; int arr[a]; for (int i = 0; i < a; i++) { cin >> arr[i]; } b = arr[0]; for (int i = 0; i < a; i++) { if (i != 0) { if (arr[i]...
7
CPP
for _ in range(int(input())): n = int(input()) l = list(map(int,input().split())) if (l[0]+l[1])<=l[-1]: print(1,2,n) else: print(-1)
7
PYTHON3
#!/usr/bin/env python3 T = int(input()) def ans(A): A = [(a, i+1) for i,a in enumerate(A)] A = sorted(A) a, ai = A[0] b, bi = A[1] c, ci = A[-1] if a + b <= c: print(ai, bi, ci) else: print(-1) for t in range(T): input() A = list(map(int, input().split())) ans...
7
PYTHON3
t = int(input()) for _ in range(t): n = int(input()) l = list(map(int,input().split())) if l[0]+l[1]<=l[-1]: print(1,2,n) else: print(-1)
7
PYTHON3
# -*- coding: utf-8 -*- """ Created on Fri Aug 14 20:11:56 2020 @author: The Wonder Land """ for _ in range(int(input())): n = int(input()) val = list(map(int, input().strip().split())) index = [1, 2] sum_tri = val[0] + val[1] for i in range(2, len(val)): #print("i =", i) if (val[i...
7
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") ...
8
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...
8
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...
8
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...
8
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]) ...
8
PYTHON3
#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...
8
CPP
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(...
8
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...
8
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...
8
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...
8
PYTHON3
#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 ...
8
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][...
8
CPP
# ------------------- 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...
8
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)) ...
8
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...
8
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...
8
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]==...
8
PYTHON3
#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 ...
8
CPP
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'] ...
8
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])...
8
PYTHON3
#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]; ...
8
CPP
""" 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...
8
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": ...
8
PYTHON3
#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...
8
CPP
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 ==...
8
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))...
8
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...
8
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' :...
8
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...
8
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]==...
8
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'): ...
8
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': ...
8
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 = ...
8
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...
8
PYTHON3
#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...
8
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]; } ...
8
CPP
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[...
8
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 ...
8
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...
8
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)) ...
8
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...
8
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...
8
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): ...
8
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 ...
8
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)...
8
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,...
8
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(...
8
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...
8
PYTHON3
#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); ...
8
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])...
8
CPP
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) ...
8
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)) ...
8
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...
8
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...
8
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(...
8
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...
8
PYTHON3
#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; } ...
8
CPP
# 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'))) ...
8
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'): ...
8
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() ...
8
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...
8
PYTHON3