input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
import sys
h, w, m = list(map(int, input().split()))
row = [0]*h
col = [0]*w
bomb = set()
for x in sys.stdin.readlines():
H, W = list(map(int, x.split()))
bomb.add((H-1, W-1))
row[H-1] += 1
col[W-1] += 1
maxrow = max(row)
maxcol = max(col)
ans = maxcol + maxrow - 1
p, q = [], []
for i ... | import sys
def main():
h, w, m = list(map(int, input().split()))
row = [0]*h
col = [0]*w
bomb = set()
for x in sys.stdin.readlines():
H, W = list(map(int, x.split()))
bomb.add((H-1, W-1))
row[H-1] += 1
col[W-1] += 1
maxrow = max(row)
maxcol =... | p02580 |
h,w,m = list(map(int,input().split()))
bombw = [0]*w
bombh = [0]*h
bomb = [[0 for j in range(w)] for i in range(h)]
# print(bomb)
for i in range(m):
hi,wi = list(map(int,input().split()))
bombw[wi-1] += 1
bombh[hi-1] += 1
bomb[hi-1][wi-1] = 1
# print(bomb)
maw = max(bombw)
mah = max(bo... | h,w,m = list(map(int,input().split()))
bombw = [0]*w
bombh = [0]*h
bomb = []
# print(bomb)
for i in range(m):
hi,wi = list(map(int,input().split()))
bombw[wi-1] += 1
bombh[hi-1] += 1
bomb.append([str(hi-1)+"-"+str(wi-1)])
# print(bomb)
maw = max(bombw)
mah = max(bombh)
# print(maw,mah... | p02580 |
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator i... | from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator i... | p02580 |
H, W, M, *HW = list(map(int, open(0).read().split()))
R = HW[::2]
C = HW[1::2]
A = [0] * (H + 1)
B = [0] * (W + 1)
for h, w in zip(*[iter(HW)] * 2):
A[h] += 1
B[w] += 1
S = set(zip(*[iter(HW)] * 2))
ans = 0
for r in R:
for c in C:
ans = max(ans, A[r] + B[c] - ((r, c) in S))
pr... | H, W, M, *HW = list(map(int, open(0).read().split()))
HW = list(zip(*[iter(HW)] * 2))
A = [0] * (H + 1)
B = [0] * (W + 1)
for h, w in HW:
A[h] += 1
B[w] += 1
a = max(A)
b = max(B)
cnt = A.count(a) * B.count(b) - len([0 for h, w in HW if A[h] == a and B[w] == b])
print((a + b - (cnt == 0))) | p02580 |
import sys
H, W, M = list(map(int, sys.stdin.readline().split()))
hlst = {}
wlst = {}
hwlst = []
for i in range(M):
h, w = sys.stdin.readline().split()
if h in hlst:
hlst[h] += 1
else:
hlst[h] = 1
if w in wlst:
wlst[w] += 1
else:
wlst[w] = 1
h... | import sys
H, W, M = list(map(int, sys.stdin.readline().split()))
hlst = {}
wlst = {}
hwlst = []
for i in range(M):
h, w = list(map(int, sys.stdin.readline().split()))
if h in hlst:
hlst[h] += 1
else:
hlst[h] = 1
if w in wlst:
wlst[w] += 1
else:
wlst... | p02580 |
H,W,M=list(map(int,input().strip().split()))
h=[0 for _ in range(H)]
w=[0 for _ in range(W)]
dp=[[0 for _ in range(W)] for _ in range(H)]
for m in range(M):
i,j=list(map(int,input().strip().split()))
dp[i-1][j-1]=1
h[i-1]+=1
w[j-1]+=1
h_max=0
hmax_l=[]
for i in range(H):
if h_max==h[... | H,W,M=list(map(int,input().strip().split()))
h=[0 for _ in range(H)]
w=[0 for _ in range(W)]
dp=[]
for m in range(M):
i,j=list(map(int,input().strip().split()))
dp.append((i,j))
h[i-1]+=1
w[j-1]+=1
h_max=0
hmax_l=[]
for i in range(H):
if h_max==h[i]:
hmax_l.append(i+1)
... | p02580 |
h,w,m = list(map(int,input().split()))
H = [0]*(h+1)
W = [0]*(w+1)
s = set([])
for i in range(m):
a,b = list(map(int,input().split()))
s.add((a,b))
H[a] += 1
W[b] += 1
x = [0]*(h+1)
y = [0]*(w+1)
for i in range(h+1):
x[i] = [i,H[i]]
for i in range(w+1):
y[i] = [i,W[i]]
... | import time
t0 = time.time()
h,w,m = list(map(int,input().split()))
H = [0]*(h+1)
W = [0]*(w+1)
s = set([])
for i in range(m):
a,b = list(map(int,input().split()))
s.add((a,b))
H[a] += 1
W[b] += 1
x = [0]*(h+1)
y = [0]*(w+1)
for i in range(h+1):
x[i] = [i,H[i]]
for i in ... | p02580 |
import collections
H, W, M = list(map(int, input().split()))
H_count = collections.defaultdict(int)
W_count = collections.defaultdict(int)
points = set()
for m in range(M):
h, w = list(map(int, input().split()))
H_count[h] += 1
W_count[w] += 1
points.add((h, w))
H_count_sort = sorted(li... | H, W, M = list(map(int, input().split()))
cnt_h = [0] * (H + 1)
cnt_w = [0] * (W + 1)
points = set()
for m in range(M):
h, w = list(map(int, input().split()))
cnt_h[h] += 1
cnt_w[w] += 1
points.add((h, w))
H_max = max(cnt_h)
W_max = max(cnt_w)
H_max_num = [i for i, cnt in enumerate(cnt_... | p02580 |
def main():
def solve(strings_max, rows_max, mapa):
summa = maxs + maxr - 1
if summa == h + w - 1 or summa == m:
return summa
for h_item in strings_max:
for w_item in rows_max:
if w_item not in mapa.get(h_item, []):
return s... | def main():
h, w, m = list(map(int, input().split()))
mapa = {}
strings = [0]*h
rows = [0]*w
for _ in range(m):
h1, w1 = list(map(int, input().split()))
if not mapa.get(h1-1, 0):
mapa[h1-1] = []
mapa[h1-1].append(w1-1)
strings[h1-1] += 1
... | p02580 |
from collections import deque
H, W, M = list(map(int, input().split()))
grid = [[0 for _ in range(W)] for _ in range(H)]
counth = deque([0 for k in range(H)])
countw = deque([0 for k in range(W)])
for k in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
grid[h][w] = 1
counth[h] += 1
... | from collections import deque
H, W, M = list(map(int, input().split()))
bomb = []
counth = deque([0 for k in range(H)])
countw = deque([0 for k in range(W)])
for k in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
bomb.append([h, w])
counth[h] += 1
countw[w] += 1
maxh = max(co... | p02580 |
from collections import deque
H, W, M = list(map(int, input().split()))
bomb = []
counth = deque([0 for k in range(H)])
countw = deque([0 for k in range(W)])
for k in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
bomb.append(h+ w*H)
counth[h] += 1
countw[w] += 1
def binary_se... | from collections import deque
H, W, M = list(map(int, input().split()))
bomb = []
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
bomb.append(h+ w*H)
counth[h] += 1
countw[w] += 1
counth = deque(counth)
count... | p02580 |
H, W, M = list(map(int, input().split()))
hw = []
cnt_h, cnt_w = [0] * H, [0] * W
for i in range(M):
x, y = list(map(int, input().split()))
hw.append((x - 1, y - 1))
cnt_h[x - 1] += 1
cnt_w[y - 1] += 1
max_h, max_w = max(cnt_h), max(cnt_w)
h_list = [h for h in range(H) if cnt_h[h] == max_h]... | H, W, M = list(map(int, input().split()))
hw = set()
cnt_h, cnt_w = [0] * H, [0] * W
for i in range(M):
x, y = list(map(int, input().split()))
hw.add((x - 1, y - 1))
cnt_h[x - 1] += 1
cnt_w[y - 1] += 1
max_h, max_w = max(cnt_h), max(cnt_w)
h_list = [h for h in range(H) if cnt_h[h] == max_h]... | p02580 |
def my_index_multi(l, x):
return [k for k, _x in enumerate(l) if _x == x]
h,w,m = list(map(int,input().split()))
l_h = [0]*(h+1)
l_w = [0]*(w+1)
a = min(h*w,3*10**5)
l_hw = [[0 for _ in range(a)] for __ in range(h+1)]
for x in range(m):
h,w = list(map(int,input().split()))
l_h[h] += 1
l_w[... | def my_index_multi(l, x):
return [k for k, _x in enumerate(l) if _x == x]
h,w,m = list(map(int,input().split()))
l_h = [0]*(h+1)
l_w = [0]*(w+1)
l_hw = [[] for _ in range(h+1)]
for _ in range(m):
h,w = list(map(int,input().split()))
l_h[h] += 1
l_w[w] += 1
l_hw[h].append(w)
m_h = ma... | p02580 |
import itertools
def my_index_multi(l, x):
return [k for k, _x in enumerate(l) if _x == x]
h,w,m = list(map(int,input().split()))
l_h = [0]*(h+1)
l_w = [0]*(w+1)
l_hw = [[] for _ in range(h+1)]
for _ in range(m):
h,w = list(map(int,input().split()))
l_h[h] += 1
l_w[w] += 1
l_hw[h].app... | import sys
import itertools
input = sys.stdin.readline
def my_index_multi(l, x):
return [k for k, _x in enumerate(l) if _x == x]
h,w,m = list(map(int,input().split()))
l_h = [0]*(h+1)
l_w = [0]*(w+1)
l_b = set()
for _ in range(m):
h,w = list(map(int,input().split()))
l_h[h] += 1
l_w[... | p02580 |
h,w,m=list(map(int,input().split()))
s=[0]*m
t=[0]*m
temp=[0]*m
for i in range(m):
sm,tm=list(map(int,input().split()))
s[i]=sm
t[i]=tm
temp[i]=[s[i],t[i]]
st=[0]*h
tt=[0]*w
for i in range(m):
st[s[i]-1]=st[s[i]-1]+1
tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
m... | h,w,m=list(map(int,input().split()))
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
sm,tm=list(map(int,input().split()))
s[i]=sm
t[i]=tm
temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
st[s[i]-1]=st[s[i]-1]+1
tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
... | p02580 |
h,w,m=list(map(int, input().split()))
r = [0]*max(h,w)
c = [0]*max(h,w)
l=[]
for i in range(m):
x,y=list(map(int, input().split()))
r[x-1]+=1
c[y-1]+=1
l.append([x,y])
cm = max(c)
rm = max(r)
ci = [i for i, x in enumerate(c) if x == cm]
ri = [i for i, x in enumerate(r) if x == rm]
ans =... | h,w,m=list(map(int, input().split()))
r = [0]*max(h,w)
c = [0]*max(h,w)
l=[]
for i in range(m):
x,y=list(map(int, input().split()))
r[x-1]+=1
c[y-1]+=1
l.append([x,y])
cm = max(c)
rm = max(r)
ci = [i for i, x in enumerate(c) if x == cm]
ri = [i for i, x in enumerate(r) if x == rm]
ans =... | p02580 |
def comp(v,w):
if v[0]<w[0] or (v[0]==w[0] and v[1]<w[1]):
return 1
elif v==w:
return 0
else:
return -1
def mergesort(list0):
n=len(list0)
if n<=1:
return list0
else:
a=mergesort(list0[0:n//2])
b=mergesort(list0[n//2:n])
r... | h,w,m=list(map(int,input().split()))
g=[]
e1=[0]*h
e2=[0]*w
for c in range(m):
a,b=list(map(int,input().split()))
g.append([a-1,b-1])
e1[a-1]+=1
e2[b-1]+=1
p1=max(e1)
p2=max(e2)
x=[1 if e1[c]==p1 else 0 for c in range(h)]
y=[1 if e2[c]==p2 else 0 for c in range(w)]
r=sum(x)*sum(y)
for i in... | p02580 |
H, W, M = list(map(int, input().split()))
hrz = [0]*H
vrt = [0]*W
targets = set()
for _ in range(M):
h, w = list([int(x) - 1 for x in input().split()])
targets.add((h, w))
hrz[h] += 1
vrt[w] += 1
hrz_max = max(hrz)
vrt_max = max(vrt)
for h in [i for i in range(H) if hrz[i] == hrz_max]:
... | H, W, M = list(map(int, input().split()))
hrz = [0]*H
vrt = [0]*W
targets = set()
for _ in range(M):
h, w = list([int(x) - 1 for x in input().split()])
targets.add((h, w))
hrz[h] += 1
vrt[w] += 1
hrz_max = max(hrz)
vrt_max = max(vrt)
hrz_max_lines = [i for i in range(H) if hrz[i] == hrz_max... | p02580 |
import sys
input = sys.stdin.readline
l = []
sh,sw,m = list(map(int,input().split()))
H = [0]*sh
W = [0]*sw
for i in range(m):
h,w = list(map(int,input().split()))
l.append((h-1,w-1))
H[h-1] += 1
W[w-1] += 1
maxh = max(H)
maxw = max(W)
# print(H,W)
# print(maxh,maxw)
hlist = []
wli... | import sys
input = sys.stdin.readline
l = set()
sh,sw,m = list(map(int,input().split()))
H = [0]*sh
W = [0]*sw
for i in range(m):
h,w = list(map(int,input().split()))
l.add((h-1,w-1))
H[h-1] += 1
W[w-1] += 1
maxh = max(H)
maxw = max(W)
# print(H,W)
# print(maxh,maxw)
hlist = []
wli... | p02580 |
from collections import Counter
def solver():
H, W, M = list(map(int, input().split()))
retu = Counter()
gyo = Counter()
ipt = [[] for _ in range(H)]
for _ in range(M):
a, b = list(map(int, input().split()))
retu[a-1] += 1
gyo[b-1] += 1
ipt[a-1].appe... | from collections import Counter
def solver():
H, W, M = list(map(int, input().split()))
retu = Counter()
gyo = Counter()
ipt = [set() for _ in range(H)]
for _ in range(M):
a, b = list(map(int, input().split()))
retu[a-1] += 1
gyo[b-1] += 1
ipt[a-1].a... | p02580 |
h, w, m = list(map(int, input().split()))
bom_list = []
h_list = [0] * h
w_list = [0] * w
for i in range(m):
a, b = list(map(int, input().split()))
bom_list.append([a - 1, b - 1])
h_list[a - 1] += 1
w_list[b - 1] += 1
max_h = max(h_list)
max_h_list = [i for i, x in enumerate(h_list) if x... | h, w, m = list(map(int, input().split()))
bom_list = []
h_list = [0] * h
w_list = [0] * w
for i in range(m):
a, b = list(map(int, input().split()))
bom_list.append([a - 1, b - 1])
h_list[a - 1] += 1
w_list[b - 1] += 1
max_h = max(h_list)
max_w = max(w_list)
ans = max_h + max_w
count = ... | p02580 |
import sys
input = sys.stdin.buffer.readline
H, W, M = list(map(int, input().split()))
bomb_h = [0] * H
bomb_w = [0] * W
grid = [[False] * W for _ in range(H)]
max_h = 0
max_w = 0
h_indices = []
w_indices = []
for i in range(M):
h, w = list(map(int, input().split()))
bomb_h[h-1] += 1
bo... | import sys
input = sys.stdin.buffer.readline
H, W, M = list(map(int, input().split()))
bomb_h = [0] * H
bomb_w = [0] * W
bomb = set()
for i in range(M):
h, w = list(map(int, input().split()))
bomb_h[h-1] += 1
bomb_w[w-1] += 1
bomb.add((h-1, w-1))
max_h = max(bomb_h)
max_w = max(bomb_w)... | p02580 |
H,W,M=list(map(int,input().split()))
HSum=[0 for _ in range(H)]
WSum=[0 for _ in range(W)]
bombs = set()
for _ in range(M):
hi,wi = [int(x)-1 for x in input().split()]
HSum[hi] += 1
WSum[wi] += 1
bombs.add( (hi,wi) )
# print(HSum)
# print(WSum)
curMax = 0
## 計算量多すぎ。。
# for h in range(H)... |
H,W,M=list(map(int,input().split()))
HSum=[0 for _ in range(H)]
WSum=[0 for _ in range(W)]
bombs = set()
for _ in range(M):
hi,wi = [int(x)-1 for x in input().split()]
HSum[hi] += 1
WSum[wi] += 1
bombs.add( (hi,wi) )
# print(HSum)
# print(WSum)
curMax = 0
## 計算量多すぎ。。
# for h in range(H)... | p02580 |
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(eval(input()))
def F(): return float(eval(input()))
def SS(): return eval(input())
def LI(): return [int(x) for x in input().spl... | import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(eval(input()))
def F(): return float(eval(input()))
def SS(): return eval(input())
def LI(): return [int(x) for x in input().spl... | p02580 |
h, w, m = list(map(int, input().split()))
h_cnt = [0] * h
w_cnt = [0] * w
bomb_list = []
for i in range(m):
h_, w_ = list(map(int, input().split()))
h_ -= 1
w_ -= 1
h_cnt[h_] += 1
w_cnt[w_] += 1
bomb_list.append((h_, w_))
max_h = max(h_cnt)
max_h_idx = []
for i in range(h):
... | h, w, m = list(map(int, input().split()))
h_cnt = [0] * h
w_cnt = [0] * w
bomb_set = set()
for i in range(m):
h_, w_ = list(map(int, input().split()))
h_ -= 1
w_ -= 1
h_cnt[h_] += 1
w_cnt[w_] += 1
bomb_set.add((h_, w_))
max_h = max(h_cnt)
max_h_idx = []
for i in range(h):
... | p02580 |
from sys import exit
H, W, M = list(map(int, input().split()))
b = [[False] * W for _ in range(H)]
r = [0] * H
c = [0] * W
for _ in range(M):
h, w = list(map(int, input().split()))
b[h-1][w-1] = True
r[h-1] += 1
c[w-1] += 1
list_r, list_c = [], []
max_r, max_c = max(r), max(c)
for i ... | from sys import exit
H, W, M = list(map(int, input().split()))
r = [0] * H
c = [0] * W
l = []
for _ in range(M):
h, w = list(map(int, input().split()))
l.append([h-1, w-1])
r[h-1] += 1
c[w-1] += 1
set_r = set()
set_c = set()
max_r, max_c = max(r), max(c)
for i in range(H):
if r... | p02580 |
"""
Satwik_Tiwari ;) .
21st AUGUST , 2020 - FRIDAY
"""
#===============================================================================================
#importing some useful libraries.
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
... | """
Satwik_Tiwari ;) .
21st AUGUST , 2020 - FRIDAY
"""
#===============================================================================================
#importing some useful libraries.
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
... | p02580 |
import copy
import sys
H, W, M= list(map(int,input().split()))
height = [0]*H
width = [0]*W
object = []
for s in sys.stdin.readlines():
h, w = list(map(int, s.split()))
height[h-1] += 1
width[w-1] += 1
object.append([h-1, w-1])
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []... | import copy
import sys
H, W, M= list(map(int,input().split()))
height = [0]*H
width = [0]*W
object = []
for s in sys.stdin.readlines():
h, w = list(map(int, s.split()))
height[h-1] += 1
width[w-1] += 1
object.append([h-1, w-1])
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []... | p02580 |
H, W, M = [int(n) for n in input().split()]
H_freq = [0] * H
W_freq = [0] * W
coordinates = {}
for m in range(M):
h, w = [int(n)-1 for n in input().split()]
H_freq[h] += 1
W_freq[w] += 1
if h in list(coordinates.keys()):
coordinates[h].append(w)
else:
coordinates[h] = [w... | H, W, M = [int(n) for n in input().split()]
H_freq = [0] * H
W_freq = [0] * W
table = []
for m in range(M):
h, w = [int(n)-1 for n in input().split()]
H_freq[h] += 1
W_freq[w] += 1
table.append((h, w))
max_h = max(H_freq)
max_w = max(W_freq)
most_freqent_h = [i for i, h in enumerate(H_fre... | p02580 |
h, w, m = list(map(int, input().split()))
target = set()
rows = [0] * h
cols = [0] * w
for i in range(m):
y, x = [int(x) - 1 for x in input().split()]
rows[y] += 1
cols[x] += 1
target.add((y, x))
rows_sorted = [(a, i) for i, a in enumerate(rows)]
rows_sorted.sort(reverse=True)
cols_sorted... | h, w, m = list(map(int, input().split()))
target_pos = set()
target_n_row = [0] * h
target_n_col = [0] * w
for i in range(m):
y, x = [int(x) - 1 for x in input().split()]
target_n_row[y] += 1
target_n_col[x] += 1
target_pos.add((y, x))
sorted_row = [(a, i) for i, a in enumerate(target_n_row... | p02580 |
h, w, m = list(map(int, input().split()))
mp = set()
hp = [0] * h
wp = [0] * w
for i in range(m):
a, b = list(map(int, input().split()))
mp.add((a,b))
l = [a, b]
hp[l[0]-1] += 1
wp[l[1]-1] += 1
hpdex = [i for i, x in enumerate(hp) if x == max(hp)]
wpdex = [i for i, x in enumerate(... | h, w, m = list(map(int, input().split()))
mp = set()
hp = [0] * h
wp = [0] * w
for i in range(m):
a, b = list(map(int, input().split()))
mp.add((a, b))
l = [a, b]
hp[l[0]-1] += 1
wp[l[1]-1] += 1
maxhp = max(hp)
maxwp = max(wp)
hpdex = [i for i, x in enumerate(hp) if x == maxhp]
wp... | p02580 |
h, w, m = list(map(int, input().split()))
a_list = []
b_list = []
h_list = [0 for _ in range(h)]
w_list = [0 for _ in range(w)]
for i in range(m):
a, b = list(map(int, input().split()))
a_list.append([a,b])
h_list[a - 1] += 1
w_list[b - 1] += 1
w_flag = [0 for _ in range(w)]
for i in range(w)... | h, w, m = list(map(int, input().split()))
a_list = []
b_list = []
h_list = [0 for _ in range(h)]
w_list = [0 for _ in range(w)]
for i in range(m):
a, b = list(map(int, input().split()))
a_list.append([a,b])
h_list[a - 1] += 1
w_list[b - 1] += 1
h_max = max(h_list)
w_max = max(w_list)
w_flag ... | p02580 |
from collections import Counter
def solve():
H, W, M = list(map(int, input().split()))
dh, dw = Counter(), Counter()
used = set()
for _ in range(M):
h, w = list(map(int, input().split()))
dh[h] += 1
dw[w] += 1
used.add((h, w))
ih = dh.most_common()
... | from collections import Counter
def solve():
H, W, M = list(map(int, input().split()))
dh, dw = Counter(), Counter()
used = set()
for _ in range(M):
h, w = list(map(int, input().split()))
dh[h] += 1
dw[w] += 1
used.add((h, w))
ih = dh.most_common()
... | p02580 |
H, W, M = [int(i) for i in input().split()]
cnt_dict_h = {}
cnt_dict_w = {}
bomb_list = []
for i in range(M):
h, w = [int(i)-1 for i in input().split()]
bomb_list.append((h,w))
cnt_dict_h.setdefault(h, 0)
cnt_dict_h[h] += 1
cnt_dict_w.setdefault(w, 0)
cnt_dict_w[w] += 1
max_h_ke... | H, W, M = [int(i) for i in input().split()]
sum_h = [0] * W
sum_w = [0] * H
bomb_list = set()
for _ in range(M):
h, w = [int(i) for i in input().split()]
h -= 1
w -= 1
bomb_list.add((h,w))
sum_h[w] += 1
sum_w[h] += 1
max_sum_h = max(sum_h)
max_sum_w = max(sum_w)
output = max_s... | p02580 |
import sys
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))
B=set([tuple(map(int,input().split())) for i in range(M)])
HH=[0]*(H+1)
WW=[0]*(W+1)
for x,y in B:
HH[x]+=1
WW[y]+=1
MAXH=max(HH)
MAXW=max(WW)
ANS=MAXH+MAXW-1
for i in range(1,H+1):
if HH[i]!=MAXH:
c... | import sys
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))
B=set([tuple(map(int,input().split())) for i in range(M)])
HH=[0]*(H+1)
WW=[0]*(W+1)
for x,y in B:
HH[x]+=1
WW[y]+=1
MAXH=max(HH)
MAXW=max(WW)
ANS=MAXH+MAXW-1
HLIST=[]
WLIST=[]
for i in range(1,H+1):
if HH[... | p02580 |
import sys,math,collections,itertools
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))
bom = [] #ボムの場所
bomH =[0]*(H+1)
bomW=[0]*(W+1)
for _ in range(M):
h,w=list(map(int,input().split()))
bom.append((h,w))
bomH[h]+=1
bomW[w]+=1
#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = ... | import sys,math,collections,itertools
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))
bom = [] #ボムの場所
bomH =[0]*(H+1)
bomW=[0]*(W+1)
for _ in range(M):
h,w=list(map(int,input().split()))
bom.append((h,w))
bomH[h]+=1
bomW[w]+=1
#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = ... | p02580 |
H, W, M = list(map(int, input().split()))
cntH = {}
cntW = {}
bomb = set()
for i in range(M):
h, w = list(map(int, input().split()))
bomb.add((h-1,w-1))
cntH[h-1] = cntH.get(h-1, 0) + 1
cntW[w-1] = cntW.get(w-1, 0) + 1
max_H_list = [kv[0] for kv in list(cntH.items()) if kv[1] == max(cntH.valu... | H, W, M = list(map(int, input().split()))
cntH = {}
cntW = {}
bomb = set()
for i in range(M):
h, w = list(map(int, input().split()))
bomb.add((h-1, w-1))
cntH[h-1] = cntH.get(h-1, 0) + 1
cntW[w-1] = cntW.get(w-1, 0) + 1
maxH, maxW = max(cntH.values()), max(cntW.values())
max_H_list = [kv[0] ... | p02580 |
h, w, m = list(map(int, input().split()))
count_row = [0 for _ in range(h)]
count_col = [0 for _ in range(w)]
X = [[0 for i in range(w)] for _ in range(h)]
max_col = 0
max_row = 0
max_row_index = []
max_col_index = []
for i in range(m):
mh, mw = list(map(int, input().split()))
X[mh-1][mw-1] = 1
c... | h, w, m = list(map(int, input().split()))
count_row = [0 for _ in range(h)]
count_col = [0 for _ in range(w)]
# X = [[0 for i in range(w)] for _ in range(h)]
max_col = 0
max_row = 0
max_row_index = []
max_col_index = []
M = set()
for i in range(m):
mh, mw = list(map(int, input().split()))
# X[mh-1][m... | p02580 |
h, w, m = list(map(int, input().split()))
count_row = [0 for _ in range(h)]
count_col = [0 for _ in range(w)]
# X = [[0 for i in range(w)] for _ in range(h)]
M = set()
for i in range(m):
mh, mw = list(map(int, input().split()))
# X[mh-1][mw-1] = 1
M.add((mh-1, mw-1))
# M[i] = [mh, mw]
coun... | h, w, m = list(map(int, input().split()))
count_row = [0 for _ in range(h)]
count_col = [0 for _ in range(w)]
max_col = 0
max_row = 0
max_row_index = []
max_col_index = []
M = set()
for i in range(m):
mh, mw = list(map(int, input().split()))
M.add((mh-1, mw-1))
count_row[mh-1] += 1
count_col... | p02580 |
import sys
H, W, M = list(map(int, input().split()))
X = [set() for _ in range(H)]
Y = [set() for _ in range(W)]
for s in sys.stdin.readlines():
h, w = [int(x) - 1 for x in s.split()]
X[h].add(w)
Y[w].add(h)
cntX = []
cntY = []
for x in X:
cntX.append((len(x), x))
for w, y in enumerate(Y... | import sys
H, W, M = list(map(int, input().split()))
bomb = [tuple([int(x) - 1 for x in s.split()]) for s in sys.stdin.readlines()]
X = [0] * H
Y = [0] * W
for h, w in bomb:
X[h] += 1
Y[w] += 1
maxX = max(X)
maxY = max(Y)
R = []
C = []
for h, x in enumerate(X):
if x == maxX:
R.ap... | p02580 |
from sys import exit, stdin
# import copy
from collections import deque, Counter
# import numpy as np
input = stdin.readline
H, W, M = list(map(int, input().split()))
col = Counter()
row = Counter()
D = Counter()
for i in range(M):
h, w = list(map(int, input().split()))
row.update([h])
c... | from sys import exit, stdin
# import copy
from collections import deque, Counter
# import numpy as np
input = stdin.readline
H, W, M = list(map(int, input().split()))
col = Counter()
row = Counter()
D = Counter()
for i in range(M):
h, w = input().split()
row.update([h])
col.update([w])
... | p02580 |
H,W,m = list(map(int,input().split()))
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1] for i in range(H+1)]
for i in range(m):
a,b = list(map(int,input().split()))
h[a] += 1
w[b] += 1
c[a].append(b)
mh = max(h)
mw = max(w)
hkouho = []
wkouho = []
for i in range(H+1):
if h[i] == mh:
hkou... |
from bisect import bisect_left
import sys
input = sys.stdin.readline
H,W,m = list(map(int,input().split()))
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1,10**6] for i in range(H+1)]
for i in range(m):
a,b = list(map(int,input().split()))
h[a] += 1
w[b] += 1
c[a].append(b)
mh = max(h)
mw = max(w)
... | p02580 |
from bisect import bisect_left
import sys
input = sys.stdin.readline
H,W,m = list(map(int,input().split()))
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1,10**6] for i in range(H+1)]
for i in range(m):
a,b = list(map(int,input().split()))
h[a] += 1
w[b] += 1
c[a].append(b)
mh = max(h)
mw = max(w)
... | from bisect import bisect_left
import sys
input = sys.stdin.readline
H,W,m = list(map(int,input().split()))
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1,10**6] for i in range(H+1)]
for i in range(m):
a,b = list(map(int,input().split()))
h[a] += 1
w[b] += 1
c[a].append(b)
mh = max(h)
mw = max(w)
hk... | p02580 |
from bisect import bisect_left
import sys
input = sys.stdin.readline
H,W,m = list(map(int,input().split()))
h = [0]*(H+1)
w = [0]*(W+1)
c = [[-1,10**6] for i in range(H+1)]
for i in range(m):
a,b = list(map(int,input().split()))
h[a] += 1
w[b] += 1
c[a].append(b)
mh = max(h)
mw = max(w)
hk... | from bisect import bisect_left
import sys
input = sys.stdin.readline
H,W,m = list(map(int,input().split()))
h = [0]*(H+1)
w = [0]*(W+1)
c = [{-1,10**6} for i in range(H+1)]
for i in range(m):
a,b = list(map(int,input().split()))
h[a] += 1
w[b] += 1
c[a].add(b)
mh = max(h)
mw = max(w)
hkouh... | p02580 |
from bisect import bisect_left
import sys
input = sys.stdin.readline
H,W,m = list(map(int,input().split()))
h = [0]*(H+1)
w = [0]*(W+1)
c = [{-1,10**6} for i in range(H+1)]
for i in range(m):
a,b = list(map(int,input().split()))
h[a] += 1
w[b] += 1
c[a].add(b)
mh = max(h)
mw = max(w)
hkouh... | # from bisect import bisect_left
import sys
input = sys.stdin.readline
H,W,m = list(map(int,input().split()))
h = [0]*(H+1)
w = [0]*(W+1)
c = [{-1,10**6} for i in range(H+1)]
for i in range(m):
a,b = list(map(int,input().split()))
h[a] += 1
w[b] += 1
c[a].add(b)
mh = max(h)
mw = max(w)
# h... | p02580 |
H, W, M = list(map(int, input().split()))
bomb = [0] * M
H_list = [0] * H
W_list = [0] * W
for i in range(M):
h, w = list(map(int, input().split()))
bomb[i] = [h - 1, w - 1]
H_list[h - 1] += 1
W_list[w - 1] += 1
#print(HW, H_list, W_list)
H_max = max(H_list)
W_max = max(W_list)
H_index = []
... | H, W, M = list(map(int, input().split()))
bomb = [0] * M
H_list = [0] * H
W_list = [0] * W
for i in range(M):
h, w = list(map(int, input().split()))
bomb[i] = [h - 1, w - 1]
H_list[h - 1] += 1
W_list[w - 1] += 1
#print(HW, H_list, W_list)
H_max = max(H_list)
W_max = max(W_list)
H_count = H_li... | p02580 |
def solve():
H, W, M = list(map(int, input().split()))
N = 3 * 10 ** 5
cnth = [0] * N
cntw = [0] * N
dic = dict()
for i in range(M):
h, w = [int(x) - 1 for x in input().split()]
cnth[h] += 1
cntw[w] += 1
dic[(h, w)] = 1
mh = max(cnth)
mw = max(... | def solve():
H, W, M = list(map(int, input().split()))
N = 3 * 10 ** 5
cnth = [0] * N
cntw = [0] * N
st = set()
for i in range(M):
h, w = [int(x) - 1 for x in input().split()]
cnth[h] += 1
cntw[w] += 1
st.add((h, w))
mh = max(cnth)
mw = max(cnt... | p02580 |
H, W, M = list(map(int, input().split()))
hw = []
sum_h = [0] * W
sum_w = [0] * H
for _ in range(M):
h, w = list(map(int, input().split()))
hw.append([h, w])
h -= 1
w -= 1
sum_h[w] += 1
sum_w[h] += 1
max_h = max(sum_h)
max_w = max(sum_w)
new_H = [h for h in range(H) if sum_w[h... | H, W, M = list(map(int, input().split()))
hw = set()
sum_h = [0] * W
sum_w = [0] * H
for _ in range(M):
h, w = list(map(int, input().split()))
hw.add((h, w))
h -= 1
w -= 1
sum_h[w] += 1
sum_w[h] += 1
max_h = max(sum_h)
max_w = max(sum_w)
new_H = [h for h in range(H) if sum_w[h... | p02580 |
H, W, M = list(map(int, input().split()))
bombs = []
rows = [[]for _ in range(H)]
cols = [[]for _ in range(W)]
for _ in range(M):
h, w = [int(x)-1 for x in input().split()]
bombs.append((h, w))
rows[h].append(w)
cols[w].append(h)
max_row = 0
row_idx = set()
for i, row in enumerate(rows):
... | import sys
input = sys.stdin.readline
H, W, M = list(map(int, input().split()))
bombs = []
rows = [[]for _ in range(H)]
cols = [[]for _ in range(W)]
for _ in range(M):
h, w = [int(x)-1 for x in input().split()]
bombs.append((h, w))
rows[h].append(w)
cols[w].append(h)
max_row = 0
row_idx = ... | p02580 |
H,W,M=list(map(int,input().split()))
h=[0]*M
w=[0]*M
for i in range(M):
h[i],w[i]=list(map(int,input().split()))
t=[0]*H
y=[0]*W
for i in range(H):
a = 0
for j in range(M):
if h[j] == i+1:
a = a+1
t[i] = a
for i in range(W):
a = 0
for j in range(M):
... | H,W,M=list(map(int,input().split()))
bomb=[]
h=[0]*H
w=[0]*W
for i in range(M):
hi,wi=list(map(int,input().split()))
h[hi-1] += 1
w[wi-1] += 1
bomb.append([hi,wi])
maxh = max(h)
maxw = max(w)
ans = maxh + maxw
lh=[]
lw=[]
for i in range(len(h)):
if h[i] == maxh:
lh.appen... | p02580 |
H,W,M = list(map(int,input().split()))
T = [0] * M
H_cnt = {}
W_cnt = {}
HW = {}
for i in range(M):
h,w = list(map(int,input().split()))
if not h in H_cnt:
H_cnt[h] = 0
if not w in W_cnt:
W_cnt[w] = 0
H_cnt[h] += 1
W_cnt[w] += 1
HW[(h,w)] = 1
HL = [[h,cnt] for h,c... | H,W,M = list(map(int,input().split()))
T = [0] * M
H_cnt = {}
W_cnt = {}
HW = {}
for i in range(M):
h,w = list(map(int,input().split()))
if not h in H_cnt:
H_cnt[h] = 0
if not w in W_cnt:
W_cnt[w] = 0
H_cnt[h] += 1
W_cnt[w] += 1
HW[(h,w)] = 1
HL = [[h,cnt] for h,c... | p02580 |
from collections import defaultdict
h, w, m = list(map(int, input().split()))
HW = [list(map(int, input().split())) for _ in range(m)]
H = [i for i, _ in HW]
W = [i for _, i in HW]
hd = defaultdict(int)
wd = defaultdict(int)
for i, j in HW:
hd[i] += 1
wd[j] += 1
hd = list(hd.items())
wd = list(wd... | from collections import defaultdict
h, w, m = list(map(int, input().split()))
HW = [list(map(int, input().split())) for _ in range(m)]
dicHW = defaultdict(set)
for h, w in HW:
dicHW[h].add(w)
hd = defaultdict(int)
wd = defaultdict(int)
for i, j in HW:
hd[i] += 1
wd[j] += 1
hd = list(hd.items(... | p02580 |
import queue
h,w,m = ( int(x) for x in input().split() )
h_array = [ 0 for i in range(h) ]
w_array = [ 0 for i in range(w) ]
ps = set()
for i in range(m):
hi,wi = ( int(x)-1 for x in input().split() )
h_array[hi] += 1
w_array[wi] += 1
ps.add( (hi,wi) )
h_great = max(h_array)
w_great = max(w... | h,w,m = ( int(x) for x in input().split() )
h_array = [ 0 for i in range(h) ]
w_array = [ 0 for i in range(w) ]
ps = set()
for i in range(m):
hi,wi = ( int(x)-1 for x in input().split() )
h_array[hi] += 1
w_array[wi] += 1
ps.add( (hi,wi) )
h_great = max(h_array)
w_great = max(w_array)
h_gre... | p02580 |
h,w,m = ( int(x) for x in input().split() )
h_array = [ 0 for i in range(h) ]
w_array = [ 0 for i in range(w) ]
ps = set()
for i in range(m):
hi,wi = ( int(x)-1 for x in input().split() )
h_array[hi] += 1
w_array[wi] += 1
ps.add( (hi,wi) )
h_great = max(h_array)
w_great = max(w_array)
h_gre... | import sys
input = sys.stdin.readline
h,w,m = list(map(int,input().split()))
h_array = [ 0 for i in range(h) ]
w_array = [ 0 for i in range(w) ]
ps = set()
for i in range(m):
hi,wi = [int(x) - 1 for x in input().split()]
h_array[hi] += 1
w_array[wi] += 1
ps.add( (hi,wi) )
h_great = max(... | p02580 |
import sys
input = sys.stdin.readline
h,w,m = list(map(int,input().split()))
h_array = [ 0 for i in range(h) ]
w_array = [ 0 for i in range(w) ]
ps = set()
for i in range(m):
hi,wi = [int(x) - 1 for x in input().split()]
h_array[hi] += 1
w_array[wi] += 1
ps.add( (hi,wi) )
h_great = max(... | import sys
input = sys.stdin.readline
def main():
h,w,m = list(map(int,input().split()))
h_array = [ 0 for _ in range(h) ]
w_array = [ 0 for _ in range(w) ]
ps = set()
for i in range(m):
hi,wi = [int(x) - 1 for x in input().split()]
h_array[hi] += 1
w_array[wi] ... | p02580 |
h,w,m=list(map(int,input().split()))
a=[[] for i in range(m)]
g=[0 for i in range(h)]
r=[0 for i in range(w)]
for i in range(m):
x,y=list(map(int,input().split()))
a[i].append(x)
a[i].append(y)
g[x-1]+=1
r[y-1]+=1
G=[]
R=[]
d=max(g)
e=max(r)
for i in range(h):
if g[i]==d:
... | h,w,m=list(map(int,input().split()))
a=[[] for i in range(m)]
g=[0 for i in range(h)]
r=[0 for i in range(w)]
for i in range(m):
x,y=list(map(int,input().split()))
a[i].append(x)
a[i].append(y)
g[x-1]+=1
r[y-1]+=1
G=[0 for i in range(h)]
R=[0 for i in range(w)]
d=max(g)
e=max(r)
for ... | p02580 |
# -*- coding: utf-8 -*-
H, W, M = list(map(int, input().split()))
h_list = [0 for _ in range(H + 1)]
w_list = [0 for _ in range(W + 1)]
m_list = [[0 for _ in range(W + 1)] for _ in range(H + 1)]
for i in range(M):
h, w = list(map(int, input().split()))
h_list[h] += 1
w_list[w] += 1
m_list[h][... | # -*- coding: utf-8 -*-
H, W, M = list(map(int, input().split()))
h_list = [0 for _ in range(H + 1)]
w_list = [0 for _ in range(W + 1)]
m_dic = {}
for i in range(M):
h, w = list(map(int, input().split()))
h_list[h] += 1
w_list[w] += 1
m_dic["{}_{}".format(h, w)] = 1
max_h_list = []
max_h ... | p02580 |
import itertools
h, w, m = list(map(int,input().split(' ')))
x = [0] * 300001
y = [0] * 300001
z = []
mx, my = 0, 0
for i in range(m):
a, b = list(map(int,input().split(' ')))
x[a] += 1
y[b] += 1
mx = max(mx, x[a])
my = max(my, y[b])
z.append((a, b))
x1 = [i for i in range(300001)... | import itertools
h, w, m = list(map(int,input().split(' ')))
x = [0] * 300001
y = [0] * 300001
z = []
mx, my = 0, 0
for i in range(m):
a, b = list(map(int,input().split(' ')))
x[a] += 1
y[b] += 1
mx = max(mx, x[a])
my = max(my, y[b])
z.append((a, b))
x1 = x.count(mx)
y1 = y.count... | p02580 |
import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()
def main():
H,W,m=list(map(int, input().split()))
Hline=[]
wline=[]
blist=[]
for k in range(m):
h,w=list(map(int, input().split()))
Hline.append(h)
wline.append(w)
... | import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()
def main():
H,W,m=list(map(int, input().split()))
Hline=[]
wline=[]
blist=dict()
for k in range(m):
h,w=list(map(int, input().split()))
Hline.append(h)
wline.append(w)
... | p02580 |
H, W, M = list(map(int, input().split()))
visited = set()
h_sum = [0] * H
w_sum = [0] * W
for i in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
visited.add((h, w))
h_sum[h] += 1
w_sum[w] += 1
max_h = max_w = 0
can_h = []
can_w = []
for i in range(H):
... | H, W, M = list(map(int, input().split()))
visited = set()
h_sum = [0] * H
w_sum = [0] * W
for i in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
visited.add((h, w))
h_sum[h] += 1
w_sum[w] += 1
max_h = max_w = 0
can_h = []
can_w = []
for i in range(H):
... | p02580 |
H,W,M=list(map(int,input().split()))
nh=[0]*H
nw=[0]*W
boms=[]
for _ in range(H):
boms.append([False]*W)
for _ in range(M):
h,w=list(map(int,input().split()))
nh[h-1] += 1
nw[w-1] += 1
boms[h-1][w-1]=True
maxh = max(nh)
maxw = max(nw)
i_indexes=[]
for i in range(H):
if nh[i] =... | import sys
input = sys.stdin.readline
H,W,M=list(map(int,input().split()))
nh=[0]*H
nw=[0]*W
boms=set()
for _ in range(M):
h,w=list(map(int,input().split()))
nh[h-1] += 1
nw[w-1] += 1
boms.add((h-1, w-1))
maxh = max(nh)
maxw = max(nw)
i_indexes=[]
for i in range(H):
if nh[i] == ... | p02580 |
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
h,w,m=[int(x) for x in input().split()]
#defaultdictにすることにより後に使うmax関数のコストを削減
hcnt=defaultdict(int)
wcnt=defaultdict(int)
bomb=[... | from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
h,w,m=[int(x) for x in input().split()]
#defaultdictにすることにより後に使うmax関数のコストを削減
hcnt=defaultdict(int)
wcnt=defaultdict(int)
#存在チェッ... | p02580 |
# E
from collections import Counter
H,W,M=list(map(int,input().split()))
h,w,bomb=[0]*M,[0]*M,[]
for i in range(M):
h[i],w[i]=list(map(int,input().split()))
bomb.append((h[i],w[i]))
most_h,most_w=Counter(h).most_common(),Counter(w).most_common()
def max_values(lis):
max_num=lis[0][1]
for... | H,W,M=list(map(int,input().split()))
h,w,bomb=[0]*H,[0]*W,[]
for i in range(M):
a,b=list(map(int,input().split()))
bomb.append((a-1,b-1))
h[a-1]+=1
w[b-1]+=1
max_h=max(h)
max_w=max(w)
bomb_and_max=0
for i,j in bomb:
if h[i]==max_h and w[j]==max_w:
bomb_and_max+=1
i... | p02580 |
ans=0
h,w,m=list(map(int,input().split()))
d=list()
from collections import defaultdict
r=defaultdict(int)
c=defaultdict(int)
r=[0]*(h+1)
c=[0]*(w+1)
for i in range(m):
a,b=list(map(int,input().split()))
d+=(a,b),
r[a]+=1
c[b]+=1
R=max(r)
C=max(c)
x=0
nr=r.count(R)
nc=c.count(C)
for i in r... | H, W, M = list(map(int, input().split()))
lh = [0]*(H+1)
lw = [0]*(W+1)
l = []
for _ in range(M):
h, w = list(map(int, input().split()))
lh[h] += 1
lw[w] += 1
l += [[h, w]]
maxh = max(lh)
maxw = max(lw)
cnt = 0
ch = lh.count(maxh)
cw = lw.count(maxw)
for y, x in l:
if lh[y] == maxh and lw[x... | p02580 |
H, W, M = list(map(int, input().split()))
countH = [[h, 0] for h in range(H)]
countW = [[w, 0] for w in range(W)]
Bh = {}
for i in range(M):
h, w = list(map(int, input().split()))
h, w = h-1, w-1
if h in Bh:
Bh[h].add(w)
else:
Bh[h] = {w}
countH[h][1] += 1
countW[w][1] += 1
countH.s... | H, W, M = list(map(int, input().split()))
countH = [0 for h in range(H)]
countW = [0 for w in range(W)]
Bh = {}
for i in range(M):
h, w = list(map(int, input().split()))
h, w = h-1, w-1
if h in Bh:
Bh[h].add(w)
else:
Bh[h] = {w}
countH[h] += 1
countW[w] += 1
maxh = 0
ch = []
maxw ... | p02580 |
from bisect import bisect_left, bisect_right
def exists(ite, x):
return bool(bisect_right(ite, x) - bisect_left(ite, x))
H, W, M = list(map(int,input().split()))
targets = [list([int(x) - 1 for x in input().split()]) for i in range(M)]
cnth = [0] * H
cntw = [0] * W
wlist = [[] for i in range(H)]
for i ... | from bisect import bisect_left, bisect_right
H, W, M = list(map(int,input().split()))
targets = [list([int(x) - 1 for x in input().split()]) for i in range(M)]
cnth = [0] * H
cntw = [0] * W
wlist = [[] for i in range(H)]
for i in range(M):
hi, wi = targets[i]
cnth[hi] += 1
cntw[wi] += 1
wlist[hi].ap... | p02580 |
H, W, M = list(map(int, input().split()))
bombs = []
for i in range(H):
bombs.append([False] * W)
rows = []
for i in range(H):
rows.append([i, 0])
cols = []
for i in range(W):
cols.append([i, 0])
for i in range(M):
y, x = [x - 1 for x in list(map(int, input().split()))]
bombs[y][x] = Tru... | H, W, M = list(map(int, input().split()))
bombs = {}
rows = []
cols = []
for i in range(H):
rows.append([i, 0])
for i in range(W):
cols.append([i, 0])
for i in range(M):
y, x = [x - 1 for x in list(map(int, input().split()))]
bombs[(y,x)] = True
rows[y][1] += 1
cols[x][1] += 1
r... | p02580 |
import sys
input = sys.stdin.readline
h, w, m = list(map(int,input().split()))
row = [0]*h
col = [0]*w
enemy = []
for i in range(m):
hh, ww = [int(x)-1 for x in input().split()]
row[hh] += 1
col[ww] += 1
enemy.append((hh,ww))
enemy = set(enemy)
rmax = max(row)
cmax = max(col)
rin... | import sys
input = sys.stdin.readline
h, w, m = list(map(int,input().split()))
row = [0]*h
col = [0]*w
enemy = []
for i in range(m):
hh, ww = [int(x)-1 for x in input().split()]
row[hh] += 1
col[ww] += 1
enemy.append((hh,ww))
enemy = set(enemy)
rmax = max(row)
cmax = max(col)
on_... | p02580 |
H, W, M = list(map(int, input().split()))
h = [0] * (H + 1)
w = [0] * (W + 1)
boms = set()
for _ in range(M):
x, y = list(map(int, input().split()))
h[x - 1] += 1
w[y - 1] += 1
boms.add((x, y))
h_max = max(h)
w_max = max(w)
h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx... | H, W, M = list(map(int, input().split()))
h = [0] * H
w = [0] * W
boms = set()
for _ in range(M):
x, y = list(map(int, input().split()))
h[x - 1] += 1
w[y - 1] += 1
boms.add((x, y))
h_max = max(h)
w_max = max(w)
h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 fo... | p02580 |
h, w, m = list(map(int, input().split()))
nh = [0 for i in range(h)]
nw = [0 for j in range(w)]
bomb = [[] for i in range(h)]
for i in range(m):
inp = list(map(int, input().split()))
nh[inp[0] - 1] += 1
nw[inp[1] - 1] += 1
bomb[inp[0]-1].append(inp[1]-1)
maxh = max(nh)
maxw = max(nw)
counth =... | h, w, m = list(map(int, input().split()))
nh = [0 for i in range(h)]
nw = [0 for j in range(w)]
bomb = [set() for i in range(h)]
for i in range(m):
inp = list(map(int, input().split()))
nh[inp[0] - 1] += 1
nw[inp[1] - 1] += 1
bomb[inp[0]-1].add(inp[1]-1)
maxh = max(nh)
maxw = max(nw)
counth =... | p02580 |
# coding: utf-8
# Your code here!
# 幅優先探索(行きがけ)
import collections
import sys
import copy
import re
import math
import itertools
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(... | # coding: utf-8
# Your code here!
# 幅優先探索(行きがけ)
import collections
import sys
import copy
import re
import math
import itertools
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(... | p02580 |
from collections import Counter
import sys
H,W,M,*hw = list(map(int,open(0).read().split()))
h = hw[::2]
w = hw[1::2]
hw_set = set((hi,wi) for hi,wi in zip(h,w))
raw_count = Counter(h)
col_count = Counter(w)
raw_max = raw_count.most_common()[0][1]
col_max = col_count.most_common()[0][1]
ans = 0
... | from collections import Counter
import sys
H,W,M,*hw = list(map(int,open(0).read().split()))
h = hw[::2]
w = hw[1::2]
hw_set = set((hi,wi) for hi,wi in zip(h,w))
raw_count = Counter(h).most_common()
col_count = Counter(w).most_common()
raw_max = raw_count[0][1]
col_max = col_count[0][1]
ans = ... | p02580 |
H, W, M = list(map(int, input().split()))
bomb = []
row = [0] * H
column = [0] * W
for i in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
bomb.append([h, w])
row[h] += 1
column[w] += 1
row_max = max(row)
col_max = max(column)
r_check = []
c_... | H, W, M = list(map(int, input().split()))
bomb = set()
row = [0] * H
column = [0] * W
for i in range(M):
h, w = list(map(int, input().split()))
h -= 1
w -= 1
bomb.add((h, w))
row[h] += 1
column[w] += 1
row_max = max(row)
col_max = max(column)
r_check = []
c_... | p02580 |
import sys
input = sys.stdin.readline
H, W, M = list(map(int, input().split()))
h_count = [0]*H
w_count = [0]*W
HW = [tuple(map(int, input().split())) for _ in range(M)]
map = [[False]*W for _ in range(H)]
for h, w in HW:
h_count[h-1] += 1
w_count[w-1] += 1
map[h-1][w-1] = True
h_max, w_max = 0... | import sys
input = sys.stdin.readline
H, W, M = list(map(int, input().split()))
h_count = [0]*H
w_count = [0]*W
HW = [tuple(map(int, input().split())) for _ in range(M)]
for h, w in HW:
h_count[h-1] += 1
w_count[w-1] += 1
h_max, w_max = 0, 0
hs, ws = [], []
for i in range(H):
if h_max < h_coun... | p02580 |
import itertools
H,W,M = list(map(int,input().split()))
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
x,y = list(map(int,input().split()))
lsx[x] += 1
lsy[y] += 1
lsxy.append((x,y))
maxx = max(lsx)
maxy = max(lsy)
lsmaxx = [i for i, x in enumerate(lsx) if x == maxx]
lsmax... | import itertools
H,W,M = list(map(int,input().split()))
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
x,y = list(map(int,input().split()))
lsx[x] += 1
lsy[y] += 1
lsxy.append((x,y))
maxx = max(lsx)
maxy = max(lsy)
lsmaxx = [i for i, x in enumerate(lsx) if x == maxx]
lsmax... | p02580 |
H,W,M = list(map(int,input().split()))
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
x,y = list(map(int,input().split()))
lsx[x] += 1
lsy[y] += 1
lsxy.append([x,y])
maxx = max(lsx)
maxy = max(lsy)
lsmaxx = [i for i, x in enumerate(lsx) if x == maxx]
lsmaxy = [i for i, x in... | H,W,M = list(map(int,input().split()))
lsx = [0] + [0]*H
lsy = [0] + [0]*W
lsxy = []
for i in range(M):
x,y = list(map(int,input().split()))
lsx[x] += 1
lsy[y] += 1
lsxy.append([x,y])
maxx = max(lsx)
maxy = max(lsy)
cx = lsx.count(maxx)
cy = lsy.count(maxy)
al = cx*cy
for i in range(M):
... | p02580 |
from itertools import product
H,W,M = list(map(int,input().split()))
h_list = [0] * M
w_list = [0] * M
for m in range(M):
h_list[m],w_list[m] = list(map(int,input().split()))
hh_list = [0] * H
ww_list = [0] * W
for m in range(M):
hh_list[h_list[m]-1] += 1
for m in range(M):
ww_list[w_list[m]-1] +... | from itertools import product
H,W,M = list(map(int,input().split()))
h_list = [0] * M
w_list = [0] * M
for m in range(M):
h_list[m],w_list[m] = list(map(int,input().split()))
hh_list = [0] * H
ww_list = [0] * W
for m in range(M):
hh_list[h_list[m]-1] += 1
for m in range(M):
ww_list[w_list[m]-1] +... | p02580 |
from collections import defaultdict
def solve(H, M, W, bombs):
count_h = defaultdict(int)
count_w = defaultdict(int)
for b in bombs:
h = str(b[0])
count_h[h] += 1
w = str(b[1])
count_w[w] += 1
max_h = max(count_h.values())
max_w = max(count_w.values())
... | import sys
def solve():
readline = sys.stdin.readline
H, W, M = list(map(int, readline().split()))
h = [0] * H
w = [0] * W
b = set()
for _ in range(M):
y, x = list(map(int, readline().split()))
x -= 1
y -= 1
h[y] += 1
w[x] += 1
b.a... | p02580 |
import sys
import math
import collections
import bisect
import itertools
# import numpy as np
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353
ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda... | import sys
import math
import collections
import bisect
import itertools
# import numpy as np
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353
ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na = lambda... | p02580 |
H, W, M = list(map(int, input().split()))
bomb = [list(map(int, input().split())) for i in range(M)]
column_cnt = [0]*W
row_cnt = [0]*H
for i in range(M):
row_cnt[bomb[i][0]-1] += 1
column_cnt[bomb[i][1]-1] += 1
row_max_index = row_cnt.index(max(row_cnt))
column_max_index = column_cnt.index(max(co... | H, W, M = list(map(int, input().split()))
bomb = set([tuple(map(int, input().split())) for i in range(M)])
column_cnt = [0]*W
row_cnt = [0]*H
for bomb_pos in bomb:
row_cnt[bomb_pos[0]-1] += 1
column_cnt[bomb_pos[1]-1] += 1
row_max_index = row_cnt.index(max(row_cnt))
column_max_index = column_cnt.i... | p02580 |
from collections import Counter
def main(H, W, M, obj_h, obj_w, obj):
c_h = Counter(obj_h)
c_w = Counter(obj_w)
max_h = max(c_h.values())
max_w = max(c_w.values())
lst_h = [kv[0] for kv in list(c_h.items()) if kv[1] == max_h]
lst_w = [kv[0] for kv in list(c_w.items()) if kv[1] == max_w]... | from collections import Counter
def main(H, W, M, obj_h, obj_w, obj):
c_h = Counter(obj_h)
c_w = Counter(obj_w)
max_h = max(c_h.values())
max_w = max(c_w.values())
lst_h = [kv[0] for kv in list(c_h.items()) if kv[1] == max_h]
lst_w = [kv[0] for kv in list(c_w.items()) if kv[1] == max_w]... | p02580 |
h,w,m=list(map(int,input().split()))
HW=[list(map(int,input().split())) for _ in range(m)]
H,W=[0 for _ in range(h)],[0 for _ in range(w)]
for i,j in HW:
i,j=i-1,j-1
H[i] +=1
W[j] +=1
max_h,max_w=max(H),max(W)
ans=max_h+max_w
cnt=H.count(max_h)*W.count(max_w)
for i,j in HW:
if H[i-1]==max... | h,w,m=list(map(int,input().split()))
HW=[list(map(int,input().split())) for _ in range(m)]
H,W=[0]*h,[0]*w
for i,j in HW:
H[i-1] +=1
W[j-1] +=1
max_h,max_w=max(H),max(W)
ans=max_h+max_w
cnt=H.count(max_h)*W.count(max_w)
for i,j in HW:
if H[i-1]==max_h and W[j-1]==max_w:
cnt -=1
print... | p02580 |
H,W,M = list(map(int, input().split()))
hs = [0] * H
ws = [0] * W
s = set()
for i in range(M):
h,w = list(map(int, input().split()))
h -= 1
w -= 1
hs[h] += 1
ws[w] += 1
s.add((h,w))
mh = 0
mw = 0
for i in range(H):
mh = max(mh,hs[i])
for j in range(W):
mw = max(mw,ws[j])
i_s = lis... | H,W,M = list(map(int, input().split()))
hs = [0] * H
ws = [0] * W
s = set()
for i in range(M):
h,w = list(map(int, input().split()))
h -= 1
w -= 1
hs[h] += 1
ws[w] += 1
s.add((h,w))
mh = 0
mw = 0
for i in range(H):
mh = max(mh, hs[i])
for j in range(W):
mw = max(mw, ws[j])
l_s... | p02580 |
H,W,M = list(map(int, input().split()))
hs = [0] * H
ws = [0] * W
s = set()
for i in range(M):
h,w = list(map(int, input().split()))
h -= 1
w -= 1
hs[h] += 1
ws[w] += 1
s.add((h,w))
mh = 0
mw = 0
for i in range(H):
mh = max(mh, hs[i])
for j in range(W):
mw = max(mw, ws[j])
i_s... | H,W,M = list(map(int, input().split()))
hs = [0] * H
ws = [0] * W
s = set()
for i in range(M):
h,w = list(map(int, input().split()))
h -= 1
w -= 1
s.add((h,w))
hs[h] += 1
ws[w] += 1
mh = 0
mw = 0
for i in range(H):
mh = max(mh, hs[i])
for j in range(W):
mw = max(mw, ws[j])
i_s =... | p02580 |
h,w,m=list(map(int,input().split()))
bomb=[list(map(int,input().split())) for _ in range(m)]
a=[0 for i in range(h+1)]
b=[0 for _ in range(w+1)]
for i in range(m):
a[bomb[i][0]]+=1
b[bomb[i][1]]+=1
am=max(a)
bm=max(b)
aa=[i for i, x in enumerate(a) if x==am]
bb=[i for i, x in enumerate(b) if x==bm]
i... | h,w,m=list(map(int,input().split()))
bomb=[list(map(int,input().split())) for _ in range(m)] #bombの位置
a=[0 for i in range(h+1)] #各行のbombの個数
b=[0 for _ in range(w+1)] #各列のbombの個数
for i in range(m):
a[bomb[i][0]]+=1
b[bomb[i][1]]+=1
am=max(a) #1行にあるbombの最大値
bm=max(b) #1列にあるbombの最大値
hmax=[0]*(h+1) #最大値をとる... | p02580 |
H, W, M = list(map(int, input().split()))
h = [0] * H
w = [0] * W
Mem = [tuple(map(int, input().split())) for _ in range(M) ]
for i, j in Mem:
h[i-1] += 1
w[j-1] += 1
maxh = max(h)
maxw = max(w)
listh = [i for i, v in enumerate(h, 1) if v == maxh]
listw = [j for j, v in enumerate(w, 1) if v == max... | h,w,m=list(map(int,input().split()))
item=[list(map(int,input().split())) for i in range(m)]
row=[0]*h
col=[0]*w
for i in range(m):
x,y=item[i]
row[x-1]+=1
col[y-1]+=1
mr,mc=max(row),max(col)
xr=set([i for i in range(h) if row[i]==mr])
xc=set([i for i in range(w) if col[i]==mc])
check=len(xr)*len... | p02580 |
H, W, M = list(map(int, input().split()))
bombs = [list([int(x) - 1 for x in input().split()]) for _ in range(M)]
field = [[False] * W for _ in range(H)]
max_hw = max(H, W)
H_count = {i:0 for i in range(max_hw)}
W_count = {i:0 for i in range(max_hw)}
for i in range(M):
h, w = bombs[i]
field[h][w] = ... | H, W, M = list(map(int, input().split()))
bombs = set()
H_count = [0 for i in range(H)]
W_count = [0 for i in range(W)]
for i in range(M):
h, w = [int(x) - 1 for x in input().split()]
bombs.add((h, w))
H_count[h] += 1
W_count[w] += 1
A = max(H_count)
B = max(W_count)
Ah = []
Bw = []
... | p02580 |
def my_index(l, x):
return [i for i, _x in enumerate(l) if _x == x]
H,W,M=list(map(int,input().split()))
P=list()
P_X=[0]*(H+1)
P_Y=[0]*(W+1)
for m in range(M):
P.append(list(map(int,input().split())))
P_X[P[m][0]]+=1
P_Y[P[m][1]]+=1
Max_X=max(P_X)
Max_Y=max(P_Y)
max_X=my_index(P_X,Max_X)... |
def my_index(l, x):
return [i for i, _x in enumerate(l) if _x == x]
H,W,M=list(map(int,input().split()))
P=list()
P_X=[0]*(H+1)
P_Y=[0]*(W+1)
for m in range(M):
P.append(list(map(int,input().split())))
P_X[P[m][0]]+=1
P_Y[P[m][1]]+=1
Max_X=max(P_X)
Max_Y=max(P_Y)
max_X=my_index(P_X,Max_... | p02580 |
H, W, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(M)]
takasa = [0]*(H)
haba = [0]*(W)
for i in range(M):
takasa[A[i][0]-1] += 1
haba[A[i][1]-1] += 1
mt = max(takasa)
mh = max(haba)
ct = takasa.count(mt)
ch = haba.count(mh)
a = 0
for i in range(M):
... | H, W, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(M)]
hl, wl = [0]*H, [0]*W
for i,j in A:
hl[i-1] += 1
wl[j-1] += 1
mt,mh = max(hl),max(wl)
a = 0
for i,j in A:
if hl[i-1] == mt and wl[j-1] == mh:
a += 1
print((mt+mh-1 if a == hl.count(mt... | p02580 |
H,W,M=list(map(int,input().split()))
mine=[list(map(int,input().split()))for i in range(M)]
mine_h=[0]*H
mine_w=[0]*W
ans=0
val=-1
for i in range(M):
mine_h[mine[i][0]-1]+=1
mine_w[mine[i][1]-1]+=1
max_h=max(mine_h)
max_w=max(mine_w)
h_index=[i+1 for i, x in enumerate(mine_h)if x == max_h]
w_index=[... | H,W,M=list(map(int,input().split()))
mine_h=[0]*H
mine_w=[0]*W
val=-1
mine=set()
for i in range(M):
a,b=list(map(int,input().split()))
mine_h[a-1]+=1
mine_w[b-1]+=1
mine.add((a,b))
max_h=max(mine_h)
max_w=max(mine_w)
h_index=[i+1 for i, x in enumerate(mine_h)if x == max_h]
w_index=[i+1 for ... | p02580 |
h,w,m=list(map(int,input().split()))
bomb=[]
x=[0]*(h+1)
y=[0]*(w+1)
for i in range(m):
h1,w1=list(map(int,input().split()))
x[h1]+=1
y[w1]+=1
bomb.append((h1,w1))
maxx=max(x)
maxy=max(y)
r=[]
c=[]
for i in range(1,h+1):
if x[i]==maxx:
r.append(i)
for j in range(1,w+1):
... | h,w,m=list(map(int,input().split()))
bomb=[]
x=[0]*(h+1)
y=[0]*(w+1)
for i in range(m):
h1,w1=list(map(int,input().split()))
x[h1]+=1
y[w1]+=1
bomb.append((h1,w1))
maxx=max(x)
maxy=max(y)
r=[]
c=[]
bomb=set(bomb)
for i in range(1,h+1):
if x[i]==maxx:
r.append(i)
for j in ran... | p02580 |
H,W,M = list(map(int,input().split()))
P = [0]*(H+1)
Q = [0]*(W+1)
A = set()
for k in range(M):
a,b = list(map(int,input().split()))
P[a] += 1
Q[b] += 1
A.add((a,b))
Pindex = [i for i, v in enumerate(P) if v == max(P)]
Qindex = [i for i, v in enumerate(Q) if v == max(Q)]
Pmax = P[Pindex[0]]
Qmax = Q... | H,W,M = list(map(int,input().split()))
P = [0]*(H+1)
Q = [0]*(W+1)
A = set()
for k in range(M):
a,b = list(map(int,input().split()))
P[a] += 1
Q[b] += 1
A.add((a,b))
Pmax = max(P)
Qmax = max(Q)
Pindex = []
Qindex = []
for i in range(H+1):
if P[i] == Pmax:
Pindex.append(i)
for... | p02580 |
from collections import Counter
H,W,m = list(map(int,input().split()))
ci = Counter([])
cj = Counter([])
s = set()
for i in range(m):
h,w = list(map(int,input().split()))
ci[h] += 1
cj[w] += 1
s.add((h,w))
mi = max(ci.values())
mj = max(cj.values())
ci = sorted(list(ci.items()),key=lambda x:... | from collections import Counter
H,W,m = list(map(int,input().split()))
ci = Counter([])
cj = Counter([])
s = set()
for i in range(m):
h,w = list(map(int,input().split()))
ci[h] += 1
cj[w] += 1
s.add((h,w))
mi = max(ci.values())
mj = max(cj.values())
ci = list(ci.items())
cj = list(cj.items(... | p02580 |
def e_bomber():
from collections import defaultdict
H, W, M = [int(i) for i in input().split()]
bomb_row = [0] * H
bomb_col = [0] * W
bomb_pos = defaultdict(int)
for _ in range(M):
r, c = [int(i) - 1 for i in input().split()]
bomb_row[r] += 1
bomb_col[c] += 1
... | def e_bomber():
import sys
input = sys.stdin.readline
H, W, M = [int(i) for i in input().split()]
bomb_row = [0] * H
bomb_col = [0] * W
bomb_pos = set()
for _ in range(M):
r, c = [int(i) - 1 for i in input().split()]
bomb_row[r] += 1
bomb_col[c] += 1
... | p02580 |
import collections as c
h,w,m = list(map(int,input().split()))
x = []
y = []
z = []
for i in range(m):
s,t = list(map(int,input().split()))
x.append(s)
y.append(t)
z.append(tuple([s,t]))
a = c.Counter(x)
b = c.Counter(y)
a = a.most_common()
b = b.most_common()
c = []
d = []
e = a[0][1]... | import collections as c
h,w,m = list(map(int,input().split()))
x = []
y = []
z = set([])
for i in range(m):
s,t = list(map(int,input().split()))
x.append(s)
y.append(t)
z.add(tuple([s,t]))
a = c.Counter(x)
b = c.Counter(y)
a = a.most_common()
b = b.most_common()
c = []
d = []
e = a[0][... | p02580 |
import sys
H, W, M = list(map(int, input().split()))
lis =[]
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
Ch, Cm = list(map(int, input().split()))
Hlis[Ch-1] += 1
Wlis[Cm-1] += 1
lis.append([Ch, Cm])
Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
W... | import sys
H, W, M = list(map(int, input().split()))
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
Ch, Cm = list(map(int, input().split()))
Hlis[Ch-1] += 1
Wlis[Cm-1] += 1
lis.add((Ch, Cm))
Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
W... | p02580 |
import os
import sys
from io import BytesIO, IOBase
def main():
h, w, m = list(map(int, input().split()))
row = [0] * h
col = [0] * w
d = set()
ma = 0
for i in range(m):
x, y = list(map(int, input().split()))
row[x - 1] += 1
col[y - 1] += 1
d.add(... | import os
import sys
from io import BytesIO, IOBase
def main():
h, w, m = list(map(int, input().split()))
row = [0] * h
col = [0] * w
d = set()
ma = 0
for i in range(m):
x, y = list(map(int, input().split()))
row[x - 1] += 1
col[y - 1] += 1
d.add(... | p02580 |
H,W,M = list(map(int,input().split()))
h_target = [0]*(H+1)
w_target = [0]*(W+1)
target = []
for _ in range(M):
h,w = list(map(int,input().split()))
target.append((h,w))
h_target[h] += 1
w_target[w] += 1
max_h = max(h_target)
max_w = max(w_target)
num_max_h = 0
num_max_w = 0
for i... | H,W,M = list(map(int,input().split()))
h_target = [0]*(H+1)
w_target = [0]*(W+1)
target = []
for _ in range(M):
h,w = list(map(int,input().split()))
target.append((h,w))
h_target[h] += 1
w_target[w] += 1
max_h = max(h_target)
max_w = max(w_target)
num_max_h = 0
num_max_w = 0
for i... | p02580 |
import sys
input = sys.stdin.readline
H, W, M = list(map(int, input().split()))
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
h, w = list(map(int, input().split()))
Hsum[h-1] += 1
Wsum[w-1] += 1
hw.add((h-1, w-1))
hcnt = Hsum.count(max(Hsum))
wcnt = Wsum.count(max(Wsum))
if hcnt ... | import sys
input = sys.stdin.readline
H, W, M = list(map(int, input().split()))
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
h, w = [int(x) - 1 for x in input().split()]
Hsum[h] += 1
Wsum[w] += 1
hw.add((h, w))
mh = max(Hsum)
mw = max(Wsum)
hidx = [i for i, _ in enumerate(Hsum) ... | p02580 |
import sys
input = sys.stdin.readline
h, w, m = list(map(int, input().split()))
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []
for i in range(m):
H, W = [int(x) - 1 for x in input().split()]
col[W] += 1
row[H] += 1
bomb.append((H, W))
maxcol = max(col)
maxrow = max(row)
xpo... | h, w, m = list(map(int, input().split()))
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []
for i in range(m):
H, W = [int(x) - 1 for x in input().split()]
col[W] += 1
row[H] += 1
bomb.append((H, W))
maxcol = max(col)
maxrow = max(row)
for i in range(w):
if col[i] == maxcol:
... | p02580 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.