From 7a02ae5ba674b6a67370cfab526fc8689358a9e9 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Sun, 9 Feb 2025 16:31:04 +0000 Subject: [PATCH] solutions(contest): 2065A, 2065B, 2065D --- solutions/python/2065A.py | 8 ++++++++ solutions/python/2065B.py | 19 +++++++++++++++++++ solutions/python/2065D.py | 24 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 solutions/python/2065A.py create mode 100644 solutions/python/2065B.py create mode 100644 solutions/python/2065D.py diff --git a/solutions/python/2065A.py b/solutions/python/2065A.py new file mode 100644 index 0000000..3db3bfd --- /dev/null +++ b/solutions/python/2065A.py @@ -0,0 +1,8 @@ +t = int(input()) + +for _ in range(t): + w = input() + + w = w[0:len(w)-2] + + print(w+"i") diff --git a/solutions/python/2065B.py b/solutions/python/2065B.py new file mode 100644 index 0000000..19fe26b --- /dev/null +++ b/solutions/python/2065B.py @@ -0,0 +1,19 @@ +t = int(input()) + +for _ in range(t): + w = list(input()) + + adjacent = False + + for i in range(1, len(w)): + if w[i] == w[i-1]: + adjacent = True + + if len(w) <= 1: + break + + if not adjacent: + print(len(w)) + continue + + print("1") diff --git a/solutions/python/2065D.py b/solutions/python/2065D.py new file mode 100644 index 0000000..41d3cca --- /dev/null +++ b/solutions/python/2065D.py @@ -0,0 +1,24 @@ +t = int(input()) + +for _ in range(t): + n, m = map(int, input().split(' ')) + + a = [] + + for _ in range(n): + a.append(list(map(int, input().split(' ')))) + + a = sorted(a, key=lambda x: sum(x))[::-1] + + concat = [] + + for i in a: + for j in i: + concat.append(j) + + total = 0 + + for idx, i in enumerate(concat): + total += (n*m-idx)*i + + print(total)