0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ABC355 C

Posted at

これ、解き方までわかって以下のコードを出したのですが、1つのケースだけ引っかかってACにならなかったのですよ。
まあ、わかればなんてことない見過ごしですがね。
悔しいのう。。。

from itertools import permutations as perm
from itertools import combinations, product, combinations_with_replacement, groupby, accumulate
from fractions import Fraction
from collections import *
from sys import * 
from bisect import *
from heapq import *

N, T = map(int, input().split())
A = list(map(int,input().split()))	

def main():
	C = [0]*N
	R = [0]*N
	X = 0
	Y = 0
	
	q = [[0]*N for _ in range(N)]
	
	#masu(N)
	for i in range(T):
		col = A[i] % N
		row = (A[i]-1) // N
		#q[row][col-1]=1
		
		#masu(q) 
		
		C[col] += 1
		if C[col] == N:
			print(i+1)
			return
		
		R[row] += 1
		if R[row] == N:
			print(i+1)
			return
		
		if A[i] % (N+1) == 1:
			X += 1
			if X == N:
				print(i+1)
				return
		
		if A[i] % (N-1) == 1 and A[i] > 1 and A[i] < (N*N):
			Y += 1
			if Y == N:
				print(i+1)
				return
		
	print(-1)
				
			
if __name__ == "__main__":
	main()

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?