input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
#134 Dodecagon print((3*(int(eval(input()))**2)))
#134 Dodecagon print((3*int(eval(input()))**2))
p02969
import itertools import fractions def main(): r = int(eval(input())) print((3 * (r**2))) if __name__ == '__main__': main()
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] #from fractions import gcd #from itertools import combinations # (string,3) 3回 #from collections import deque from collections import defaultdict #import bisect # # d = m - k...
p02969
i = int(eval(input())) print((3*i**2))
print((3*int(eval(input()))**2))
p02969
print((3 * int(eval(input()))**2))
r=int(eval(input())) print((3*r*r))
p02969
n = int(eval(input())) print((3*n*n))
r = int(eval(input())) print((3*r*r))
p02969
r = int(eval(input())) print((3*r**2))
N=int(eval(input())) print((3*N**2))
p02969
print((3*int(eval(input()))**2))
a = int(eval(input())) print((3*a**2))
p02969
r = int(eval(input())) print((3*r*r))
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): r = int(eval(input())) res = 3 * pow(r, 2) print(res) if __name__ == '__main__': resolve()
p02969
a = int(eval(input())) print((3 * a**2))
print((int(eval(input())) ** 2 * 3))
p02969
print((3 * int(eval(input())) ** 2))
R = int(eval(input())) print((3 * R ** 2))
p02969
import sys # input = sys.stdin.readline inf = 10 ** 18 P = 10 ** 9 + 7 print(( 3 * (int(eval(input())) ** 2) ))
r = int(eval(input())) print((3 * r * r))
p02969
a = int(eval(input())) print((3 * (a ** 2)))
r = int(eval(input())) print((3*r*r))
p02969
r = int(eval(input())) print((3 * r ** 2))
r = int(eval(input())) ans = 3 * r ** 2 print(ans)
p02969
r=int(eval(input())) print((3*r*r))
a=int(eval(input())) print((3*a*a))
p02969
r = int(eval(input())) print((3 * r ** 2))
r = int(eval(input())) print((3 * (r ** 2)))
p02969
n=int(eval(input())) print((3*n**2))
print((3*int(eval(input()))**2))
p02969
import sys def input(): return sys.stdin.readline().strip() def resolve(): x,y=list(map(int, input().split())) cnt=0 while x<=y: x=x*2 cnt+=1 print(cnt) resolve()
import sys def input(): return sys.stdin.readline().strip() def resolve(): x,y=list(map(int, input().split())) cnt=1 while x<=y: x*=2 cnt+=1 print((cnt-1)) resolve()
p03481
x, y = list(map(int, input().split())) ans = 1 while x*2 <= y: ans += 1 x *= 2 print(ans)
x, y = list(map(int, input().split())) if y < 2*x: print((1)) exit() ans = 1 while x*2 <= y: ans += 1 x = 2*x print(ans)
p03481
X, Y = list(map(int, input().split())) x = X ans = 0 while x < Y: x *= 2 ans += 1 print((ans if x > Y else ans + 1))
x,y = list(map(int, input().split())) n = [x] while n[-1] < y: n.append(n[-1]*2) if n[-1] > y: n.pop(-1) print((len(n)))
p03481
from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() from math import log2 x,y = readInts() ans = 0 i = 1 while 1: if x*2**(i-1)<=y: ans...
from collections import defaultdict def readInt(): return int(eval(input())) def readInts(): return list(map(int, input().split())) def readChar(): return eval(input()) def readChars(): return input().split() from math import log2 x,y = readInts() kouho = int(log2(y)-log2(x)+1)-1 ans = kouho-1 ...
p03481
import sys input = sys.stdin.readline x, y = [int(x) for x in input().split()] ans = 0 while x <= y: x *= 2 ans += 1 print(ans)
import sys input = lambda: sys.stdin.readline().rstrip() x, y = list(map(int, input().split())) cnt = 1 while True: if x*2 <= y: cnt += 1 x *= 2 else: break print(cnt)
p03481
def slove(): import sys input = sys.stdin.readline n, m = list(map(int, input().rstrip('\n').split())) cnt = 1 t = n while True: t *= 2 if t <= m: cnt += 1 else: print(cnt) exit() if __name__ == '__main__': slove()...
def slove(): import sys input = sys.stdin.readline x, y = list(map(int, input().rstrip('\n').split())) t = x cnt = 1 while True: t *= 2 if t <= y: cnt += 1 else: print(cnt) exit() if __name__ == '__main__': slove()...
p03481
x, y = list(map(int, input().split())) ans = 0 while x <= y: x *= 2 ans += 1 print(ans)
x, y = list(map(int, input().split())) ans = 0 while x <= y: ans += 1 x *= 2 print(ans)
p03481
X, Y = list(map(int, input().split())) A = X ans = 1 while 2*A <= Y: A *= 2 ans += 1 print(ans)
X, Y = list(map(int, input().split())) # A[i+1] = 2 * A[i] と構成すればよさげ # このとき A[0] = X とすれば A[n] = X * pow(2, n-1) for i in range(100): X *= 2 if X > Y: print((i+1)) exit()
p03481
x, y = list(map(int, input().split())) ans = 1 while True: x *= 2 if x > y: break ans += 1 print(ans)
x, y = list(map(int, input().split())) cnt = 0 tmp = x while tmp <= y: tmp *= 2 cnt += 1 print(cnt)
p03481
h,w,m = list(map(int,input().split())) bombDict = dict() bombDictH = dict() bombDictW = dict() for i in range(h+1): bombDict[i] = set() bombDictH[i] = 0 for i in range(w+1): bombDictW[i] = 0 for i in range(m): bombH,bombW = list(map(int,input().split())) bombDictH[bombH] += 1 ...
h,w,m = list(map(int,input().split())) bombDict = dict() bombDictH = dict() bombDictW = dict() for i in range(h+1): bombDict[i] = set() bombDictH[i] = 0 for i in range(w+1): bombDictW[i] = 0 for i in range(m): bombH,bombW = list(map(int,input().split())) bombDictH[bombH] += 1 ...
p02580
h,w,m = list(map(int,input().split())) b = [] x = [0 for _ in range(w)] y = [0 for _ in range(h)] for i in range(m): bh,bw = list(map(int,input().split())) bh -= 1 bw -= 1 b.append((bh,bw)) x[bw] += 1 y[bh] += 1 #print(b,x,y) mxx = max(x) mxy = max(y) xb = [] for i in range(w): xb.append...
h,w,m = list(map(int,input().split())) b = [] x = [0 for _ in range(w)] y = [0 for _ in range(h)] for i in range(m): bh,bw = list(map(int,input().split())) bh -= 1 bw -= 1 b.append((bh,bw)) x[bw] += 1 y[bh] += 1 #print(b,x,y) mxx = max(x) mxy = max(y) cmxb = 0 for by,bx in b: if y[by]+...
p02580
h,w,m=list(map(int,input().split())) d_h=[0]*(h+1) d_w=[0]*(w+1) d=set() for i in range(m): nh,nw=list(map(int,input().split())) d_h[nh]+=1 d_w[nw]+=1 d.add((nh,nw)) ans=0 hantei=0 for i in range(1,h+1): hantei=0 for j in range(1,w+1): if (i,j) in d: hantei=(d_h[i]+d_w[j]-1) el...
h,w,m=list(map(int,input().split())) d_h=[0]*(h+1) d_w=[0]*(w+1) d=[] for i in range(m): nh,nw=list(map(int,input().split())) d_h[nh]+=1 d_w[nw]+=1 d.append([nh,nw]) #print(d_h) #print(d_w) hantei=0 ans1=max(d_h) memoh=set() for i in range(1,h+1): hantei=d_h[i] if ans1==hantei: me...
p02580
h,w,m=list(map(int,input().split())) l=[list(map(int,input().split())) for i in range(m)] H=[0]*h W=[0]*w for i in range(m): H[l[i][0]-1]+=1 W[l[i][1]-1]+=1 hmax=max(H) wmax=max(W) cthmax=0 ctwmax=0 for i in range(h): if H[i]==hmax: cthmax+=1 for i in range(w): if W[i]==wmax: ctwmax+=1 ...
h,w,m=list(map(int,input().split())) l=[list(map(int,input().split())) for i in range(m)] H=[0]*h W=[0]*w for i in range(m): H[l[i][0]-1]+=1 W[l[i][1]-1]+=1 hmax=max(H) wmax=max(W) cthmax=0 ctwmax=0 for i in range(h): if H[i]==hmax: cthmax+=1 for i in range(w): if W[i]==wmax: ctwmax+=1 ...
p02580
import sys from copy import deepcopy as copy input = sys.stdin.readline def main(): h, w, m = list(map(int, input().split())) bomb_h = [0]*h bomb_w = [0]*w bomb_w_place = [set() for _ in range(w)] for i in range(m): x, y = list(map(int, input().split())) bomb_h[x-...
import sys input = sys.stdin.readline def main(): h, w, m = list(map(int, input().split())) bomb = [tuple(map(int, input().split())) for _ in range(m)] bom_h = [0]*h bom_w = [0]*w for i in range(m): x, y = bomb[i] bom_h[x-1] += 1 bom_w[y-1] += 1 ...
p02580
h,w,m=list(map(int,input().split())) A=[0]*h ; B=[0]*w ;G=[] for i in range(m): x,y=list(map(int,input().split())) A[x-1]+=1 ; B[y-1]+=1 G.append([x-1,y-1]) q=max(A) ; e=max(B) Q=[i for i in range(h) if A[i]==q] W=[j for j in range(w) if B[j]==e];#print(A,B,Q,W) grid={} for i in Q: for j i...
h,w,m=list(map(int,input().split())) A=[0]*h ; B=[0]*w ;G=[] for i in range(m): x,y=list(map(int,input().split())) A[x-1]+=1 ; B[y-1]+=1 G.append([x-1,y-1]) q=max(A) ; e=max(B) Q=[i for i in range(h) if A[i]==q] W=[j for j in range(w) if B[j]==e];#print(A,B,Q,W) cnt=len(Q)*len(W) for i in...
p02580
H, W, M = list(map(int, input().split())) X = [0] * W Y = [0] * H Map = [] for _ in range(M): h, w = list(map(int, input().split())) h -= 1 w -= 1 Y[h] += 1 X[w] += 1 Map.append((h, w)) MX = max(X) MY = max(Y) ans = MX + MY Xans = [] Yans = [] for i, x in enumerate(X): ...
import sys input = sys.stdin.buffer.readline H, W, M = list(map(int, input().split())) X = [0] * W Y = [0] * H Map = [] for _ in range(M): h, w = list(map(int, input().split())) h -= 1 w -= 1 Y[h] += 1 X[w] += 1 Map.append((h, w)) MX = max(X) MY = max(Y) ans = MX + MY Xan...
p02580
from collections import Counter H, W, M = list(map(int, input().split())) counterH = [0] * H counterW = [0] * W setHW = set({}) for _ in range(M): hi, wi = [int(x) - 1 for x in input().split()] setHW.add((hi, wi)) counterH[hi] += 1 counterW[wi] += 1 set_max_h, set_max_w = set(), set() m...
H, W, M = list(map(int,input().split())) Bomb = [] for _ in range(M): hi, wi = [int(x) - 1 for x in input().split()] Bomb.append((hi, wi)) counterH = [0] * H counterW = [0] * W for (hi, wi) in Bomb: counterH[hi] += 1 counterW[wi] += 1 # 最大のところを選ぶ max_h = max(counterH) max_w = max(count...
p02580
H,W,M = list(map(int, input().split())) mx=[0] * W my=[0] * H bs =[[] for i in range(H)] mxx = 0 myy = 0 for i in range(M): y,x = list(map(int, input().split())) mx[x-1] += 1 my[y-1] += 1 mxx = max(mx[x-1], mxx) myy = max(my[y-1], myy) bs[y-1].append(x-1) vx = [] vy = [] for i,x...
H,W,M = list(map(int, input().split())) mx=[0] * W my=[0] * H bs ={} mxx = 0 myy = 0 for i in range(M): y,x = list(map(int, input().split())) mx[x-1] += 1 my[y-1] += 1 mxx = max(mx[x-1], mxx) myy = max(my[y-1], myy) if y-1 in bs: bs[y-1].add(x-1) else: bs[y-1] ...
p02580
from collections import defaultdict h, w, m = list(map(int, input().split())) row_dict = defaultdict(int) col_dict = defaultdict(int) row_col_dict = defaultdict(list) for _ in range(m): row, col = list(map(int, input().split())) row_dict[row] += 1 col_dict[col] += 1 row_col_dict[row].append...
from collections import defaultdict h, w, m = list(map(int, input().split())) row_dict = defaultdict(int) col_dict = defaultdict(int) row_col_dict = defaultdict(set) for _ in range(m): row, col = list(map(int, input().split())) row_dict[row] += 1 col_dict[col] += 1 row_col_dict[row].add(col...
p02580
from collections import defaultdict h, w, m = list(map(int, input().split())) row_dict = defaultdict(int) col_dict = defaultdict(int) row_col_dict = defaultdict(set) for _ in range(m): row, col = list(map(int, input().split())) row_dict[row] += 1 col_dict[col] += 1 row_col_dict[row].add(col...
from collections import defaultdict h, w, m = list(map(int, input().split())) row_dict = defaultdict(int) col_dict = defaultdict(int) row_col_dict = defaultdict(set) for _ in range(m): row, col = list(map(int, input().split())) row_dict[row] += 1 col_dict[col] += 1 row_col_dict[row].add(col...
p02580
#import sys #import numpy as np import math #from fractions import Fraction import itertools from collections import deque from collections import Counter import heapq #from fractions import gcd #input=sys.stdin.readline import bisect h,w,m=list(map(int,input().split())) l={} u={} hw=[list(map(int,input(...
#import sys #import numpy as np import math #from fractions import Fraction import itertools from collections import deque from collections import Counter import heapq #from fractions import gcd #input=sys.stdin.readline import bisect h,w,m=list(map(int,input().split())) l={} u={} hw=[list(map(int,input(...
p02580
H,W,M=list(map(int,input().split())) height=[0]*H width=[0]*W #bomb=[0]*M bset=set() #for k in range(M): #bomb[k]=[0]*2 for j in range(M): h,w=list(map(int,input().split())) bset.add((h-1,w-1)) #bomb[j][0]=h-1 #bomb[j][1]=w-1 height[h-1]+=1 width[w-1]+=1 #print(bomb) #print(he...
H,W,M=list(map(int,input().split())) height=[0]*H width=[0]*W #bomb=[0]*M bset=set() #for k in range(M): #bomb[k]=[0]*2 for j in range(M): h,w=list(map(int,input().split())) bset.add((h-1,w-1)) #bomb[j][0]=h-1 #bomb[j][1]=w-1 height[h-1]+=1 width[w-1]+=1 #print(bomb) #print(he...
p02580
H, W, M = list(map(int, input().split())) targets = [] n_target_h = [0] * H n_target_w = [0] * W h_max = 0 w_max = 0 for i in range(M): h, w = list(map(int, input().split())) targets.append((h, w)) n_target_h[h - 1] += 1 n_target_w[w - 1] += 1 h_max = max(h_max, n_target_h[h - 1]) ...
H, W, M = list(map(int, input().split())) targets = [] n_target_h = [0] * H n_target_w = [0] * W for i in range(M): h, w = list(map(int, input().split())) targets.append((h, w)) n_target_h[h - 1] += 1 n_target_w[w - 1] += 1 h_max = max(n_target_h) w_max = max(n_target_w) bomb_h = [i +...
p02580
from bisect import bisect_left def main(): h, w, m = list(map(int, input().split())) bombs = set() cnt_row, cnt_col = [0]*(h+1), [0]*(w+1) for _ in range(m): y, x = list(map(int, input().split())) cnt_row[y] += 1 cnt_col[x] += 1 bombs.add((y, x)) ans = 0 ...
from bisect import bisect_left def main(): h, w, m = list(map(int, input().split())) bombs = set() cnt_row, cnt_col = [0]*(h+1), [0]*(w+1) for _ in range(m): y, x = list(map(int, input().split())) cnt_row[y] += 1 cnt_col[x] += 1 bombs.add((y, x)) max_cnt_row...
p02580
#!/usr/bin/env python3 import sys from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right from itertools import accumulate sys.setrecursionlimit(10**6) INF = 10**12 m = 10**9 + 7 def main(): H, W, M = list(map(int, input().split())) h = [0] * H ...
#!/usr/bin/env python3 import sys from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right from itertools import accumulate sys.setrecursionlimit(10**6) INF = 10**12 m = 10**9 + 7 def main(): H, W, M = list(map(int, input().split())) h = [0] * H ...
p02580
## coding: UTF-8 #memo:重なっている位置に爆弾があるかないかで、1こ増減することが考えられる #import numpy as np H, W, M = list(map(int,input().split())) tate = [0] * H yoko = [0] * W bomb = set() for i in range(M): hi, wi = list(map(int,input().split())) tate[hi-1] += 1 yoko[wi-1] += 1 bomb.add((hi,wi)) #print(tate...
## coding: UTF-8 #memo:重なっている位置に爆弾があるかないかで、1こ増減することが考えられる #import numpy as np H, W, M = list(map(int,input().split())) tate = [0] * H yoko = [0] * W bomb = set() for i in range(M): hi, wi = list(map(int,input().split())) tate[hi-1] += 1 yoko[wi-1] += 1 bomb.add((hi,wi)) #prin...
p02580
H, W, M = list(map(int, input().split())) h_list = [0 for _ in range(H + 1)] w_list = [0 for _ in range(W + 1)] bomb = [] for _ in range(M): h, w = list(map(int, input().split())) h_list[h] += 1 w_list[w] += 1 bomb.append([h, w]) h_max = max(h_list) w_max = max(w_list) h_index = [] w_index =...
H, W, M = list(map(int, input().split())) h_list = [0 for _ in range(H + 1)] w_list = [0 for _ in range(W + 1)] bomb = set([]) for _ in range(M): h, w = list(map(int, input().split())) h_list[h] += 1 w_list[w] += 1 bomb.add((h, w)) h_max = max(h_list) w_max = max(w_list) h_index = [] w_index...
p02580
(h,w,m),*s=[[*list(map(int,i.split()))]for i in open(0)] r,c=[0]*-~h,[0]*-~w for x,y in s: r[x]+=1 c[y]+=1 print(((R:=max(r))+(C:=max(c))-(r.count(R)*c.count(C)==sum(r[x]+c[y]==R+C for x,y in s))))
(h,w,m),*s=[[*list(map(int,i.split()))]for i in open(0)] r,c=[0]*-~h,[0]*-~w for x,y in s: r[x]+=1 c[y]+=1 R,C=max(r),max(c) print((R+C-(r.count(R)*c.count(C)==sum(r[x]+c[y]==R+C for x,y in s))))
p02580
import base64 exec(base64.b64decode(b'aW1wb3J0IHN1YnByb2Nlc3MKaW1wb3J0IHN5cwoKY29kZSA9IHIiIiIjaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Yml0c2V0PgojaW5jbHVkZSA8Y2Fzc2VydD4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPGNocm9ubz4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y29tcGxleD4KI2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxkZXF1ZT4KI2l...
# This code is generated by [Atcoder_base64](https://github.com/kyomukyomupurin/AtCoder_base64) # Original source code : """ #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <cmath> #include <complex> #include <cstring> #include <deque> #include <ioma...
p02580
import sys import collections sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): H, W, M = [int(x) for x in input().split()] HW = [[int(x) for x in input().split()] for _ in range(M)] x = set() hc = collections.Counter() wc = collections.Counter() for h...
import sys import collections sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): H, W, M = [int(x) for x in input().split()] HW = [[int(x) for x in input().split()] for _ in range(M)] x = set() hc = collections.Counter() wc = collections.Counter() for h...
p02580
import sys def input(): return sys.stdin.readline().strip() def main(): H, W, M = list(map(int, input().split())) bomb = set() yoko = [0] * W tate = [0] * H for _ in range(M): h, w = list(map(int, input().split())) bomb.add((h-1, w-1)) yoko[w - 1] += 1 ta...
import sys def input(): return sys.stdin.readline().strip() def main(): H, W, M = list(map(int, input().split())) bomb = set() yoko = [0] * W tate = [0] * H for _ in range(M): h, w = list(map(int, input().split())) bomb.add((h-1, w-1)) yoko[w - 1] += 1 ta...
p02580
from collections import Counter H, W, M = list(map(int, input().split())) count_row = Counter() count_col = Counter() count_point = Counter() for i in range(M): h, w = list(map(int, input().split())) count_row[h] += 1 count_col[w] += 1 count_point[(h, w)] += 1 max_h, max_count_row = count_ro...
from collections import Counter H, W, M = list(map(int, input().split())) count_row = Counter() count_col = Counter() count_point = Counter() for i in range(M): h, w = list(map(int, input().split())) count_row[h] += 1 count_col[w] += 1 count_point[(h, w)] += 1 max_h, max_count_row = count_ro...
p02580
import sys H,W,M = list(map(int, input().split())) grid = [[0 for _ in range(W)] for _ in range(H)] hc = [0 for h in range(H)] wc = [0 for w in range(W)] for _ in range(M): h,w = list(map(int, input().split())) h-=1 w-=1 grid[h][w] = 1 hc[h] += 1 wc[w] += 1 hmax = max(hc) wm...
H,W,M = list(map(int, input().split())) # grid = [[0 for _ in range(W)] for _ in range(H)] bombs = set() hc = [0 for h in range(H)] wc = [0 for w in range(W)] for _ in range(M): h,w = list(map(int, input().split())) h-=1 w-=1 bombs.add((h, w)) hc[h] += 1 wc[w] += 1 hmax = max(h...
p02580
# 初期入力 import sys from collections import defaultdict input = sys.stdin.readline #文字列では使わない H,W,M = list(map(int, input().split())) bom_H ={i:0 for i in range(1,H+1)} bom_W ={i:0 for i in range(1,W+1)} posision =defaultdict(int) for i in range(M): h,w = list(map(int, input().split())) bom_H[h] +=1 ...
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 # X:各行の爆破対象の個数 Y = [0] * W # Y:各列の爆破対象の個数 for h, w in bomb: X[h] += 1 Y[w] += 1 maxX = max(X) maxY = max(Y) R = [h for h, x in enumerate(X) if x == ma...
p02580
# 初期入力 import sys from collections import defaultdict input = sys.stdin.readline #文字列では使わない H,W,M = list(map(int, input().split())) bom_H =defaultdict(int) bom_W =defaultdict(int) posision =set() for i in range(M): h,w = list(map(int, input().split())) bom_H[h] +=1 bom_W[w] +=1 posision.a...
# 初期入力 import sys from collections import defaultdict input = sys.stdin.readline #文字列では使わない H,W,M = list(map(int, input().split())) bom_H =defaultdict(int) bom_W =defaultdict(int) posision =set() for i in range(M): h,w = list(map(int, input().split())) bom_H[h] +=1 bom_W[w] +=1 posision.a...
p02580
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし def ...
import sys def MI(): return list(map(int,sys.stdin.readline().rstrip().split())) H,W,M = MI() X = [0]*(H+1) # X[i] = x座標がiである爆破対象はいくつあるか Y = [0]*(W+1) # Y[i] = y座標がiである爆破対象はいくつあるか from collections import defaultdict d = defaultdict(int) # d[(h,w)] == 1 ⇔ 座標(h,w)に爆破対象が存在する for i in range(M): h,w =...
p02580
import collections import sys *data, = list(map(int, sys.stdin.read().split()[::-1])) def inp(): return data.pop() h, w, m = inp(), inp(), inp() targets = set() xs = [] ys = [] for _ in range(m): y, x = inp(), inp() # y -= 1 # x -= 1 ys.append(y) xs.append(x) targets...
import collections import sys *data, = list(map(int, sys.stdin.read().split()[::-1])) def inp(): return data.pop() h, w, m = inp(), inp(), inp() targets = set() xs = [] ys = [] for _ in range(m): y, x = inp(), inp() # y -= 1 # x -= 1 ys.append(y) xs.append(x) targets...
p02580
h, w, m = list(map(int, input().split())) bomb = [[False for i in range(w)] for j in range(h)] cnth = [0 for i in range(h)] cntw = [0 for i in range(w)] for i in range(m): x, y = list(map(int, input().split())) x -= 1 y -= 1 cnth[x] += 1 cntw[y] += 1 bomb[x][y] = True maxh = max(cnth) maxw = m...
h, w, m = list(map(int, input().split())) bomb = [] cnth = [0 for i in range(h)] cntw = [0 for i in range(w)] bomh = [set() for i in range(h)] bomw = [set() for i in range(w)] for i in range(m): x, y = list(map(int, input().split())) x -= 1 y -= 1 cnth[x] += 1 cntw[y] += 1 bomh[x].add(y) bo...
p02580
H,W,M=list(map(int,input().split())) s=[list(map(int,input().split())) for _ in range(M)] Tr=[0 for _ in range(H+1)] Tc=[0 for _ in range(W+1)] for i in range(M): Tr[s[i][0]]+=1 Tc[s[i][1]]+=1 mr=max(Tr) mc=max(Tc) Mr=[i for i,x in enumerate(Tr) if x==mr] Mc=[i for i,x in enumerate(Tc) if x==mc] an...
H,W,M=list(map(int,input().split())) s=[list(map(int,input().split())) for _ in range(M)] Tr=[0 for _ in range(H+1)] Tc=[0 for _ in range(W+1)] for i in range(M): Tr[s[i][0]]+=1 Tc[s[i][1]]+=1 mr=max(Tr) mc=max(Tc) Mr=[0 for _ in range(H+1)] Mc=[0 for _ in range(W+1)] Nmr=0 Nmc=0 for i in range(len...
p02580
from collections import* h,w,m=list(map(int,input().split())) d=defaultdict(int) a=[0]*h b=[0]*w for _ in range(m): x,y=list(map(int,input().split())) x-=1 y-=1 a[x]+=1 b[y]+=1 d[x*10**6+y]+=1 ma=max(a) mb=max(b) ind_x=[i for i,j in enumerate(a) if j==ma] ind_y=[i for i,j in enumerate(b) ...
h,w,m=list(map(int,input().split())) d=dict() a=[0]*h b=[0]*w for _ in range(m): x,y=list(map(int,input().split())) x-=1 y-=1 a[x]+=1 b[y]+=1 d[x*10**6+y]=1 ma=max(a) mb=max(b) ind_x=[i for i,j in enumerate(a) if j==ma] ind_y=[i for i,j in enumerate(b) if j==mb] for x in ind_x: for...
p02580
h,w,m=list(map(int,input().split())) d=dict() s=set() a=[0]*h b=[0]*w for _ in range(m): x,y=list(map(int,input().split())) x-=1 y-=1 a[x]+=1 b[y]+=1 d[x*10**6+y]=1 s.add(x*10**6+y) ma=max(a) mb=max(b) ind_x=[i for i,j in enumerate(a) if j==ma] ind_y=[i for i,j in enumerate(b) if j==mb...
h,w,m=list(map(int,input().split())) a=[0]*h;b=[0]*w s=set() for _ in range(m): x,y=[int(x)-1 for x in input().split()] a[x]+=1;b[y]+=1 s.add(x*10**6+y) ma=max(a);mb=max(b) c=[i for i,v in enumerate(a) if v==ma] d=[i for i,v in enumerate(b) if v==mb] for x in c: for y in d: if not(x*10**6+y in s...
p02580
f=lambda:map(int,input().split()) H,W,M=f() g=[set() for _ in range(H)] ch=[0]*H cw=[0]*W for _ in range(M): h,w=f() g[h-1].add(w-1) ch[h-1]+=1 cw[w-1]+=1 mh=max(ch) mw=max(cw) lh=[i for i in range(H) if ch[i]==mh] lw=[i for i in range(W) if cw[i]==mw] c=mh+mw for i in lh: if len(g[i])<1: exit...
f=lambda:list(map(int,input().split())) h,w,m=f() l,H,W=[],[0]*-~h,[0]*-~w for _ in range(m): x,y=f() l+=[(x,y)] H[x]+=1 W[y]+=1 s,t=max(H),max(W) print((s+t-(H.count(s)*W.count(t)==sum(H[x]+W[y]==s+t for x,y in l))))
p02580
import sys from collections import deque H, W, M = list(map(int, input().split())) S = list(tuple(map(int, input().split())) for _ in range(M)) hh = dict() ww = dict() for i in range(M): h, w = S[i] if h in list(hh.keys()): hh[h] += 1 else: hh[h] = 1 if w in list(ww.keys()): ...
import sys from collections import deque H, W, M = list(map(int, input().split())) S = list(tuple(map(int, input().split())) for _ in range(M)) hh = dict() ww = dict() for i in range(M): h, w = S[i] if h in list(hh.keys()): hh[h] += 1 else: hh[h] = 1 if w in list(ww.keys()): ...
p02580
h, w, m = list(map(int, input().split())) h_l = [[] for i in range(h + 1)] w_l = [[] for i in range(w + 1)] max_h = 0 max_h_l = [] max_w = 0 max_w_l = [] inputs = [] for _ in range(m): h, w = list(map(int, input().split())) inputs.append([h,w]) if h_l[h] : h_l[h][1].append(w) h_...
h, w, m = list(map(int, input().split())) h_l = [[] for i in range(h + 1)] w_l = [[] for i in range(w + 1)] max_h = 0 max_h_l = [] max_w = 0 max_w_l = [] inputs = {} for _ in range(m): h, w = list(map(int, input().split())) inputs.setdefault(h, set([w])) inputs[h].add(w) if h_l[h] : ...
p02580
import sys H, W, M = list(map(int, sys.stdin.readline().strip().split())) h = [0] * H w = [0] * W g = [[False] * W for _ in range(H)] S = set() for _ in range(M): Th, Tw = list(map(int, sys.stdin.readline().strip().split())) h[Th - 1] += 1 w[Tw - 1] += 1 # g[Th - 1][Tw - 1] = True ...
import sys H, W, M = list(map(int, sys.stdin.readline().strip().split())) h = [0] * H w = [0] * W # g = [[False] * W for _ in range(H)] S = set() for _ in range(M): Th, Tw = list(map(int, sys.stdin.readline().strip().split())) h[Th - 1] += 1 w[Tw - 1] += 1 # g[Th - 1][Tw - 1] = True ...
p02580
h, w, m = list(map(int, input().split())) hw_map = [[0 for i in range(w)] for j in range(h)] h_bomb_list = [0 for i in range(h)] w_bomb_list = [0 for i in range(w)] for i in range(m): bh, bw = list(map(int, input().split())) hw_map[bh-1][bw-1] = 1 h_bomb_list[bh-1] += 1 w_bomb_list[bw-1] += 1 ...
h, w, m = list(map(int, input().split())) h_b_list = [0 for i in range(h)] w_b_list = [0 for i in range(w)] targets = [] for i in range(m): bh, bw = list(map(int, input().split())) targets.append([bh, bw]) h_b_list[bh-1] += 1 w_b_list[bw-1] += 1 h_max = max(h_b_list) w_max = max(w_b_list) ...
p02580
import sys from bisect import bisect_left as bl input = sys.stdin.readline H, W, N = list(map(int, input().split())) ys = [0] * (H + 1) xs = [0] * (W + 1) a = [] base = 10 ** 6 for i in range(N): y, x = list(map(int, input().split())) ys[y] += 1 xs[x] += 1 a.append((y, x)) sy = sorted(ys[1: ]) sx ...
import sys input = sys.stdin.readline H, W, M = list(map(int, input().split())) s = set() ys = [0] * (H + 1) xs = [0] * (W + 1) for _ in range(M): y, x = list(map(int, input().split())) s.add((y, x)) ys[y] += 1 xs[x] += 1 res = 0 mxy = [] mx = max(ys) for i in range(H + 1): if ys[i] == mx: mx...
p02580
h,w,m=list(map(int,input().split())) bomb=[list(map(int,input().split())) for i in range(m)] num_h = [0] * (h+1) num_w = [0] * (w+1) bomb_set = set() for hi,wi in bomb: num_h[hi] += 1 num_w[wi] += 1 bomb_set.add((hi,wi)) max_hs = [k for k,v in enumerate(num_h) if v == max(num_h)] max_ws = [k for k...
h,w,m=list(map(int,input().split())) bomb=[list(map(int,input().split())) for i in range(m)] num_h = [0] * (h+1) num_w = [0] * (w+1) bomb_set = set() for hi,wi in bomb: num_h[hi] += 1 num_w[wi] += 1 bomb_set.add((hi,wi)) max_h = max(num_h) max_w = max(num_w) max_hs = [k for k,v in enumerate(num_h...
p02580
from itertools import product from sys import exit def maxindexes(L,Lmax): ret = [] for i in range(len(L)): if L[i] == Lmax: ret.append(i) return ret H,W,M = list(map(int,input().split())) row = [0]*H col = [0]*W bomb = [] for _ in range(M): a,b = (int(x)-1...
from itertools import product from sys import exit def maxindexes(L,Lmax): ret = [] for i in range(len(L)): if L[i] == Lmax: ret.append(i) return ret H,W,M = list(map(int,input().split())) row = [0]*H col = [0]*W bomb = set([]) for _ in range(M): a,b = (int...
p02580
import sys h,w,m = list(map(int,input().split())) h_lst = [0]*h w_lst = [0]*w memo = [] for i in range(m): x,y = list(map(int,input().split())) h_lst[x-1] += 1 w_lst[y-1] += 1 memo.append((x-1,y-1)) sh = 0 for i in range(h): if h_lst[i] > sh: sh = h_lst[i] sw = 0 for i in range(w): i...
import sys h,w,m = list(map(int,input().split())) h_lst = [[0,i] for i in range(h)] w_lst = [[0,i] for i in range(w)] memo = [] for i in range(m): x,y = list(map(int,input().split())) h_lst[x-1][0] += 1 w_lst[y-1][0] += 1 memo.append((x-1,y-1)) h_lst.sort(reverse = True) w_lst.sort(reverse = True...
p02580
from sys import stdin input = stdin.readline from collections import defaultdict, deque h, w, m = list(map(int,input().split())) row = defaultdict(int) col = defaultdict(int) grid = defaultdict(int) for _ in range(m): x,y = list(map(int,input().split())) row[x]+=1 col[y]+=1 grid[(x,y)]=1 ...
from sys import stdin input = stdin.readline from collections import defaultdict, deque h, w, m = list(map(int,input().split())) row = defaultdict(int) col = defaultdict(int) grid = defaultdict(int) for _ in range(m): x,y = list(map(int,input().split())) row[x]+=1 col[y]+=1 grid[(x,y)]=1 ...
p02580
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Co...
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from math import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Co...
p02580
#!/usr/bin/env python3 import collections import sys input=sys.stdin.readline h,w,m=list(map(int,input().split())) items=[set() for _ in range(h+1)] count_h=[0]*(h+1) count_w=[0]*(w+1) for _ in range(m): y,x=list(map(int,input().split())) items[y].add(x) count_h[y]+=1 count_w[x]+=1 coun...
#!/usr/bin/env python3 import collections import sys input=sys.stdin.readline h,w,m=list(map(int,input().split())) items=set() count_h=[0]*(h+1) count_w=[0]*(w+1) for _ in range(m): y,x=list(map(int,input().split())) items.add((y,x)) count_h[y]+=1 count_w[x]+=1 max_h=max(count_h) max_w...
p02580
#import random def putmx(lis,mx): ret=[] for (i,j) in zip(list(range(len(lis))),lis): if j==mx: ret.append(i) return ret h,w,m=list(map(int,input().split())) hb=[0]*h wb=[0]*w bmb=[] for i in range(h): bmb.append([]) for i in range(m): hh,ww=list(map(int,input().split())) hh...
#import random def putmx(lis,mx): ret=[] for (i,j) in zip(list(range(len(lis))),lis): if j==mx: ret.append(i) return ret h,w,m=list(map(int,input().split())) hb=[0]*h wb=[0]*w bmb=[] for i in range(h): bmb.append({-1}) for i in range(m): hh,ww=list(map(int,input().split())) ...
p02580
import sys sys.setrecursionlimit(1 << 25) readline = sys.stdin.buffer.readline read = sys.stdin.readline # 文字列読み込む時はこっち ra = range enu = enumerate def exit(*argv, **kwarg): print(*argv, **kwarg) sys.exit() def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv)) # 受け渡されたすべての要素からsubだけ...
import sys sys.setrecursionlimit(1 << 25) readline = sys.stdin.buffer.readline read = sys.stdin.readline # 文字列読み込む時はこっち ra = range enu = enumerate def exit(*argv, **kwarg): print(*argv, **kwarg) sys.exit() def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv)) # 受け渡されたすべての要素からsubだけ...
p02580
#!/usr/bin/env python3 def main(): import sys input = sys.stdin.readline h, w, m = list(map(int, input().split())) cnt_h = [0] * h cnt_w = [0] * w bomb = [[False] * w for _ in range(h)] for _ in range(m): y, x = [int(x) - 1 for x in input().split()] cnt_h[y] += 1 ...
#!/usr/bin/env python3 def main(): import sys input = sys.stdin.readline h, w, m = list(map(int, input().split())) cnt_h = [0] * h cnt_w = [0] * w bomb = set() for _ in range(m): y, x = [int(x) - 1 for x in input().split()] cnt_h[y] += 1 cnt_w[x] += 1 ...
p02580
import sys input = sys.stdin.buffer.readline def main(): H, W, M = list(map(int, input().split())) #HW = [0]*m HC = [0]*H WC = [0]*W A = [0]*M for i in range(M): h, w = list(map(int, input().split())) h, w = h-1, w-1 #HW[i] = (h, w) HC[h] += ...
import sys import io, os #input = sys.stdin.buffer.readline input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline h, w, m = list(map(int, input().split())) R = [0]*h C = [0]*w YX = [] for i in range(m): y, x = list(map(int, input().split())) y, x = y-1, x-1 R[y] +=1 C[x] +=1 YX....
p02580
import sys H, W, M = list(map(int,input().split())) R = [0] * H C = [0] * W S = set() for _ in range(M): h, w = list(map(int,input().split())) S.add((h-1, w-1)) R[h-1] += 1 C[w-1] += 1 r = max(R) c = max(C) HL = [i for i in range(H) if R[i] == r] WL = [i for i in range(W) if C[i] ...
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())) R[h-1] += 1 C[w-1] += 1 L.append([h-1, w-1]) r = max(R) c = max(C) print((r + c - (R.count(r) * C.count(c) == sum(R[h] + C[w] == r + c for h, w in L))))
p02580
import sys sys.setrecursionlimit(10**7) readline = sys.stdin.buffer.readline def readstr():return readline().rstrip().decode() def readstrs():return list(readline().decode().split()) def readint():return int(readline()) def readints():return list(map(int,readline().split())) def printrows(x):print(('\n'.join(m...
import sys sys.setrecursionlimit(10**7) readline = sys.stdin.buffer.readline def readstr():return readline().rstrip().decode() def readstrs():return list(readline().decode().split()) def readint():return int(readline()) def readints():return list(map(int,readline().split())) def printrows(x):print(('\n'.join(m...
p02580
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from...
p02580
import sys from collections import Counter H,W,m = list(map(int,input().split())) h_ls = [0] * H w_ls = [0] * W bombers = [[0,0] for _ in range(m)] for i in range(m): h,w = list(map(int,input().split())) h_ls[h-1] += 1 w_ls[w-1] += 1 bombers[i] = [h-1,w-1] h_max = max(h_ls) h_counter = Cou...
import sys from collections import Counter H,W,m = list(map(int,input().split())) h_ls = [0] * H w_ls = [0] * W bombers = [(0,0) for _ in range(m)] for i in range(m): h,w = list(map(int,input().split())) h_ls[h-1] += 1 w_ls[w-1] += 1 bombers[i] = (h-1,w-1) h_max = max(h_ls) h_counter = Cou...
p02580
import sys input = sys.stdin.readline def segfunc(x,y): return max(x,y) class SegmentTree(object): def __init__(self, A, dot, unit): n = 1 << (len(A) - 1).bit_length() tree = [unit] * (2 * n) for i, v in enumerate(A): tree[i + n] = v for i in range(n - 1, ...
H,W,M = list(map(int,input().split())) Bomb = [] H_num = [0 for _ in range(H)] W_num = [0 for _ in range(W)] for i in range(M): a,b = list(map(int,input().split())) a-=1;b-=1 Bomb.append([a,b]) H_num[a] += 1 W_num[b] += 1 HMAX = max(H_num);WMAX = max(W_num) ans = HMAX+WMAX HMAX_list = set([]); W...
p02580
from collections import defaultdict h, w, m = list(map(int, input().split())) cnt_h = [0] * h cnt_w = [0] * w dic = defaultdict(int) for _ in range(m): h_m, w_m = list(map(int, input().split())) cnt_h[h_m - 1] += 1 cnt_w[w_m - 1] += 1 dic[h_m - 1, w_m - 1] += 1 max_h = max(cnt_h) max_...
from collections import defaultdict h, w, m = list(map(int, input().split())) cnt_h = [0] * h cnt_w = [0] * w dic = defaultdict(int) for _ in range(m): h_m, w_m = list(map(int, input().split())) cnt_h[h_m - 1] += 1 cnt_w[w_m - 1] += 1 dic[(h_m - 1, w_m - 1)] += 1 max_h = max(cnt_h) ma...
p02580
import sys import random H,W,M=list(map(int,input().split())) hlist=[0]*H wlist=[0]*W hwset=set() for _ in range(M): h,w=list(map(int,input().split())) hlist[h-1]+=1 wlist[w-1]+=1 hwset.add((h-1,w-1)) hmax=max(hlist) wmax=max(wlist) hlist2=[] for i in range(H): if hlist[i]==hmax: h...
import sys H,W,M=list(map(int,input().split())) hlist=[0]*H wlist=[0]*W hwset=set() for _ in range(M): h,w=list(map(int,input().split())) hlist[h-1]+=1 wlist[w-1]+=1 hwset.add((h-1,w-1)) hmax=max(hlist) hlist2=[] for i in range(H): if hlist[i]==hmax: hlist2.append(i) wmax=max(wlist)...
p02580
import collections H,W,M=list(map(int,input().split())) h=[None]*M w=[None]*M for i in range(M): h[i],w[i]=list(map(int,input().split())) c1=collections.Counter(h) c2=collections.Counter(w) cnt=0 ans=0 for i in range(min(len(c1),20)): for j in range(min(len(c2),20)): for x in range(M): ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines H, W, M = list(map(int, readline().split())) bomb = [tuple([int(x) - 1 for x in s.split()]) for s in readlines()] X = [0] * H Y = [0] * W for h, w in bomb: X[h] += 1 Y[w] += 1 maxX = ...
p02580
H, W, M = list(map(int, input().split())) hws = [list([int(x)-1 for x in input().split()]) for _ in range(M)] booms = [set() for _ in range(H)] yoko = [0 for _ in range(W)] tate = [0 for _ in range(H)] for hw in hws: tate[hw[0]] += 1 yoko[hw[1]] += 1 booms[hw[0]].add(hw[1]) max_tate = m...
H, W, M = list(map(int, input().split())) hws = [list([int(x)-1 for x in input().split()]) for _ in range(M)] booms = [set() for _ in range(H)] yoko = [0 for _ in range(W)] tate = [0 for _ in range(H)] for hw in hws: tate[hw[0]] += 1 yoko[hw[1]] += 1 booms[hw[0]].add(hw[1]) max_tate = m...
p02580
h, w, m = list(map(int, input().split())) target_points = {tuple([int(x) - 1 for x in input().split()]) for _ in range(m)} row_points = [0] * h col_points = [0] * w for row, col in target_points: row_points[row] += 1 col_points[col] += 1 row_max = max(row_points) col_max = max(col_points) row_max...
h, w, m = list(map(int, input().split())) target_points = {tuple([int(x) - 1 for x in input().split()]) for _ in range(m)} row_points = [0] * h col_points = [0] * w for row, col in target_points: row_points[row] += 1 col_points[col] += 1 row_max = max(row_points) col_max = max(col_points) row_max...
p02580
h,w,m = list(map(int,input().split())) hli = [0]*h wli = [0]*w li = [] for i in range(m): a,b = list(map(int,input().split())) li.append([a,b]) hli[a-1] += 1 wli[b-1] += 1 a = max(hli) b = max(wli) hli2 = [] wli2 = [] for i in range(h): if hli[i] == a: hli2.append(i+1) for i ...
h,w,m = list(map(int,input().split())) hli = [0]*h wli = [0]*w li = [] liset = set() for i in range(m): a,b = list(map(int,input().split())) li.append([a,b]) liset.add((a,b)) hli[a-1] += 1 wli[b-1] += 1 a = max(hli) b = max(wli) hli2 = [] wli2 = [] for i in range(h): if hli[i] ==...
p02580
h,w,m=list(map(int,input().split())) H=[0]*(3*10**5+1) W=[0]*(3*10**5+1) M=[] for i in range(m): h,w=list(map(int,input().split())) M.append([h,w]) H[h]+=1 W[w]+=1 p=max(H) q=max(W) X=set([i for i in range(3*10**5+1) if H[i]==p]) Y=set([i for i in range(3*10**5+1) if W[i]==q]) Z=[[M[i...
h,w,m=list(map(int,input().split())) H=[0]*(3*10**5+1) W=[0]*(3*10**5+1) M=[] for i in range(m): h,w=list(map(int,input().split())) M.append([h,w]) H[h]+=1 W[w]+=1 p=max(H) q=max(W) X=set([i for i in range(3*10**5+1) if H[i]==p]) Y=set([i for i in range(3*10**5+1) if W[i]==q]) cnt=0 ...
p02580
from collections import defaultdict H,W,M=list(map(int,input().split())) AB=[tuple(map(int,input().split()))for i in range(M)] AB=[(a-1,b-1)for a,b in AB] st=set(AB) Wc=defaultdict(lambda :0) Hc=defaultdict(lambda :0) for a,b in AB: Hc[a]+=1 Wc[b]+=1 Hm=max(Hc.values()) hhh=list(Hc.keys()) w...
H,W,M=list(map(int,input().split())) HW=[tuple(map(int,input().split()))for i in range(M)] HW=[(h-1,w-1)for h,w in HW] st=set(HW) countH=[0]*H countW=[0]*W for h,w in HW: countH[h]+=1 countW[w]+=1 maxH=max(countH) maxW=max(countW) candiH=[] candiW=[] for i in range(H): if maxH==countH[i]: ...
p02580
from collections import defaultdict as ddict H,W,M=list(map(int,input().split())) tgts=set() for _ in range(M): i,j=list(map(int,input().split())) tgts.add((i,j)) rows=ddict(int) cols=ddict(int) ii=jj=0 ia,ja=[],[] for i,j in tgts: rows[i]+=1 cols[j]+=1 x=rows[i] if x>ii: ...
from collections import defaultdict as ddict ii=jj=0 ia,ja=[],[] rows=ddict(int) cols=ddict(int) H,W,M=list(map(int,input().split())) tgts=set() for _ in range(M): i,j=list(map(int,input().split())) tgts.add((i,j)) rows[i]+=1 cols[j]+=1 x=rows[i] if x>ii: ii=x ...
p02580
from collections import defaultdict as ddict h,w,m=list(map(int,input().split())) xs=[0]*w ys=[0]*h xsmx=ysmx=0 pts=set() for _ in range(m): y,x=list(map(int,input().split())) x,y=x-1,y-1 xs[x]+=1 ys[y]+=1 pts.add((x,y)) xsmx=max(xsmx,xs[x]) ysmx=max(ysmx,ys[y]) xsc=[x fo...
h,w,m=list(map(int,input().split())) xsct=[0]*w ysct=[0]*h ips=set() xsmx=ysmx=0 for _ in range(m): y,x=list(map(int,input().split())) x,y=x-1,y-1 xsct[x]+=1 ysct[y]+=1 ips.add((x,y)) xsmx=max(xsmx,xsct[x]) ysmx=max(ysmx,ysct[y]) xs=[x for x in range(w) if xsct[x]==xsmx] ys...
p02580
h,w,m=list(map(int,input().split())) cx=[0]*w cy=[0]*h xy=set() for _ in range(m): y,x=list(map(int,input().split())) x,y=x-1,y-1 cx[x]+=1 cy[y]+=1 xy.add((x,y)) xmx=max(cx) ymx=max(cy) xs=[x for x in range(w) if cx[x]==xmx] ys=[y for y in range(h) if cy[y]==ymx] ans=xmx+ymx-1 o...
h,w,m=list(map(int,input().split())) r=[0]*h c=[0]*w s=set() for _ in range(m): i,j=list(map(int,input().split())) i-=1 j-=1 r[i]+=1 c[j]+=1 s.add(i*w+j) rmx=max(r) cmx=max(c) rc=[i for i in range(h) if r[i]==rmx] cc=[j for j in range(w) if c[j]==cmx] ans=rmx+cmx-1 ok=False...
p02580
h,w,m=list(map(int,input().split())) r=[0]*h c=[0]*w s=set() for _ in range(m): i,j=list(map(int,input().split())) i-=1 j-=1 r[i]+=1 c[j]+=1 s.add(i*w+j) rmx=max(r) cmx=max(c) rc=[i for i in range(h) if r[i]==rmx] cc=[j for j in range(w) if c[j]==cmx] ans=rmx+cmx-1 ok=False...
h,w,m=list(map(int,input().split())) r=[0]*h c=[0]*w s=set() for _ in range(m): i,j=list(map(int,input().split())) i-=1 j-=1 r[i]+=1 c[j]+=1 s.add(i*w+j) rmx=max(r) cmx=max(c) rc=[i for i in range(h) if r[i]==rmx] cc=[j for j in range(w) if c[j]==cmx] ans=rmx+cmx-1 for i in...
p02580
from collections import deque def argmax_poss(a): if len(a) == 0: return [] all_ = [0] max_ = a[0] for i in range(1, len(a)): if a[i] > max_: all_ = [i] max_ = a[i] elif a[i] == max_: all_.append(i) return all_ h,w,m = list...
from collections import deque def argmax_poss(a): if len(a) == 0: return [] all_ = [0] max_ = a[0] for i in range(1, len(a)): if a[i] > max_: all_ = [i] max_ = a[i] elif a[i] == max_: all_.append(i) return all_ h,w,m = list...
p02580
import itertools H, W, M = list(map(int, input().split())) Bh = [0]*(H+1) Bw = [0]*(W+1) OD = set() for _ in range(M): h, w = list(map(int, input().split())) Bh[h] += 1 Bw[w] += 1 OD.add((h, w)) l1 = [i for i, x in enumerate(Bh) if x == max(Bh)] l2 = [j for j, x in enumerate(Bw) if x == m...
import itertools H, W, M = list(map(int, input().split())) Bh = [0]*(H+1) Bw = [0]*(W+1) OD = set() for _ in range(M): h, w = list(map(int, input().split())) Bh[h] += 1 Bw[w] += 1 OD.add((h, w)) M1 = max(Bh) M2 = max(Bw) l1 = [i for i, x in enumerate(Bh) if x == M1] l2 = [j for j, x in ...
p02580
from collections import defaultdict H,W,M = list(map(int,input().split())) bomb = [[0,0] for _ in range(M)] bomb_d = defaultdict(int) for i in range(M): bomb[i] = list(map(int,input().split())) bomb[i][0] -= 1 bomb[i][1] -= 1 bomb_d[tuple(bomb[i])] = 1 dh = [0]*H dw = [0]*W for i in...
from collections import defaultdict H,W,M = list(map(int,input().split())) bomb = [[0,0] for _ in range(M)] bomb_d = defaultdict(int) for i in range(M): bomb[i] = list(map(int,input().split())) bomb[i][0] -= 1 bomb[i][1] -= 1 bomb_d[tuple(bomb[i])] = 1 dh = [0]*H dw = [0]*W for i in...
p02580
# E - Bomber from collections import Counter h, w, m = list(map(int, input().split())) hw = [tuple(map(int, input().split())) for i in range(m)] ys, xs = list(zip(*hw)) ymax, = Counter(ys).most_common(1) xmax, = Counter(xs).most_common(1) bombed = max(ymax[1], xmax[1]) if bombed < m: if ymax[1] >...
# E - Bomber from collections import Counter h, w, m = list(map(int, input().split())) hw = [tuple(map(int, input().split())) for i in range(m)] ys, xs = list(zip(*hw)) ymax, = Counter(ys).most_common(1) xmax, = Counter(xs).most_common(1) bombed = max(ymax[1], xmax[1]) if bombed < m: if ymax[1] >...
p02580
import random import time start=time.time() h,w,m=map(int,input().split()) hh=[[0,i]for i in range(h)] ww=[[0,i]for i in range(w)] hw=set() for _ in range(m): a,b=map(int,input().split()) a-=1 b-=1 hh[a][0]+=1 ww[b][0]+=1 hw.add((a,b)) ww.sort(reverse=1) s=ww[0][0] w=[] for x,j in ww: if...
import random import time start=time.time() h,w,m=map(int,input().split()) hh=[[0,i]for i in range(h)] ww=[[0,i]for i in range(w)] hw=set() for _ in range(m): a,b=map(int,input().split()) a-=1 b-=1 hh[a][0]+=1 ww[b][0]+=1 hw.add((a,b)) ww.sort(reverse=1) s=ww[0][0] w=[] for x,j in ww: if...
p02580
h,w,m=map(int,input().split()) hh=[[0,i]for i in range(h)] ww=[[0,i]for i in range(w)] hw=set() for _ in range(m): a,b=map(int,input().split()) a-=1 b-=1 hh[a][0]+=1 ww[b][0]+=1 hw.add((a,b)) ww.sort(reverse=1) s=ww[0][0] w=[] for x,j in ww: if x==s:w.append(j) ans=0 t=max(hh)[0] for j i...
h,w,m=map(int,input().split()) hh=[[0,i]for i in range(h)] ww=[[0,i]for i in range(w)] hw=set() for _ in range(m): a,b=map(int,input().split()) a-=1 b-=1 hh[a][0]+=1 ww[b][0]+=1 hw.add((a,b)) ww.sort(reverse=1) s=ww[0][0] w=[] for x,j in ww: if x==s:w.append(j) hh.sort(reverse=1) ans=0 t...
p02580
h,w,m=map(int,input().split()) hh=[[0,i]for i in range(h)] ww=[[0,i]for i in range(w)] hw=set() for _ in range(m): a,b=map(int,input().split()) a-=1 b-=1 hh[a][0]+=1 ww[b][0]+=1 hw.add((a,b)) ww.sort(reverse=1) s=ww[0][0] w=[] for x,j in ww: if x==s:w.append(j) hh.sort(reverse=1) ans=0 t...
import sys input = lambda: sys.stdin.readline().rstrip() h, w, m = list(map(int, input().split())) hw = [] hcount = [0] * h wcount = [0] * w for _ in range(m): a, b = list(map(int, input().split())) a -= 1 b -= 1 hcount[a] += 1 wcount[b] += 1 hw.append([a, b]) hmax = max(hcount) wmax = m...
p02580
n,m,k=list(map(int,input().split())) r=[0]*(n+1) c=[0]*(m+1) l=[] for _ in range(k): a,b=list(map(int,input().split())) l.append([a,b]) r[a]+=1 c[b]+=1 m1=max(r) x=[] for i in range(n+1): if(r[i]==m1): x.append(i) m2=max(c) y=[] for i in range(m+1): if(c[i]==m2): y.append(i) ans=m...
n,m,k=list(map(int,input().split())) m+=1 n+=1 r=[0]*(n) c=[0]*(m) d={} for _ in range(k): a,b=list(map(int,input().split())) d[(a,b)]=1 r[a]+=1 c[b]+=1 m1=max(r) x=[] for i in range(n): if(r[i]==m1): x.append(i) m2=max(c) y=[] for i in range(m): if(c[i]==m2): y.append(i) ans=m1...
p02580
H, W, M = list(map(int, input().split())) Hc = [0 for i in range(H)] Wc = [0 for i in range(W)] HW = [[0 for i in range(W)] for i in range(H)] for m in range(M): h, w = list(map(int, input().split())) Hc[h - 1] += 1 Wc[w - 1] += 1 HW[h - 1][w - 1] = 1 Hcmax = max(Hc) Hcmax_idx = [i for i, x in enu...
H, W, M = list(map(int, input().split())) Hc = [0 for i in range(H)] Wc = [0 for i in range(W)] B = [] for m in range(M): h, w = list(map(int, input().split())) Hc[h - 1] += 1 Wc[w - 1] += 1 B.append((h - 1, w - 1)) Hcmax = max(Hc) Hcmax_idx = [i for i, x in enumerate(Hc) if x == Hcmax] Wcmax = ...
p02580
#!/usr/bin/env python3 from collections import deque h, w, m = list(map(int, input().split())) hw = [tuple(map(int, input().split())) for i in range(m)] hw.sort() hw_rev = sorted(hw, key=lambda x: x[1]) index_sum_h = [] sum_h = [] index = -1 for i in hw: a, b = i if a == index: index...
#!/usr/bin/env python3 from collections import Counter h, w, m = list(map(int, input().split())) H = [] W = [] for i in range(m): hh, ww = tuple(map(int, input().split())) H.append(hh) W.append(ww) h_m = Counter(H).most_common()[0] w_m = Counter(W).most_common()[0] ans_1 = h_m[1] ans_2 = w...
p02580