about summary refs log tree commit diff
path: root/codechef
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-03-13 09:13:11 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-03-13 09:13:11 +0700
commit86fd670f4d4ac634a8c9740ff9129b589afcec1a (patch)
tree3d6e01efae1b4425f0815a0b213aca6331194818 /codechef
parent477c426b55d168764a34873561f78b3c34b1f013 (diff)
downloadcp-86fd670f4d4ac634a8c9740ff9129b589afcec1a.tar.gz
Guess my rank is gonna plummet again
Diffstat (limited to 'codechef')
-rwxr-xr-xcodechef/chdiger.py14
-rwxr-xr-xcodechef/chnum.py7
-rw-r--r--codechef/jain.c33
-rwxr-xr-xcodechef/jain.py6
4 files changed, 60 insertions, 0 deletions
diff --git a/codechef/chdiger.py b/codechef/chdiger.py
new file mode 100755
index 0000000..a3c83fb
--- /dev/null
+++ b/codechef/chdiger.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+for _ in range(int(input())):
+    n, d = input().split()
+    n, d = [int(x) for x in n], int(d)
+    for i in range(-1, -1-len(n), -1):
+        if n[i] > d:
+            n[i] = d
+        else:
+            break
+    for i in range(i, -len(n), -1):
+        if n[i] < n[i-1]:
+            n.pop(i - 1)
+            n.append(d)
+    print(''.join(map(str, n)))
diff --git a/codechef/chnum.py b/codechef/chnum.py
new file mode 100755
index 0000000..95bad50
--- /dev/null
+++ b/codechef/chnum.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+from collections import Counter
+
+for _ in range(int(input())):
+    input()
+    sizes = Counter(z // abs(z) for z in map(int, input().split())).values()
+    print(max(sizes), min(sizes))
diff --git a/codechef/jain.c b/codechef/jain.c
new file mode 100644
index 0000000..6471e93
--- /dev/null
+++ b/codechef/jain.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+
+const char VOWELS[] = {97, 101, 105, 111, 117};
+
+int main()
+{
+	char *c, s[1001];
+	long t, n, i, j, tmp;
+
+	scanf("%ld", &t);
+	while (t--) {
+		long vowels[32] = {};
+
+		scanf("%ld", &n);
+		for (i = 0; i < n; ++i) {
+			tmp = 0;
+			scanf("%s", &s);
+			for (c = s; *c; ++c) {
+				for (j = 0; VOWELS[j] ^ *c; ++j);
+				tmp |= 1 << j;
+			}
+			++vowels[tmp];
+		}
+
+		tmp = vowels[31] * (vowels[31] - 1) / 2;
+		for (i = 0; i < 31; ++i)
+			for (j = i + 1; j < 32; ++j)
+				tmp += ((i | j) == 31) * vowels[i] * vowels[j];
+		printf("%ld\n", tmp);
+	}
+
+	return 0;
+}
diff --git a/codechef/jain.py b/codechef/jain.py
new file mode 100755
index 0000000..8601072
--- /dev/null
+++ b/codechef/jain.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+from itertools import combinations
+
+for _ in range(int(input())):
+    print(sum(len(a | b) == 5 for a, b in combinations(
+        (set(input()) for d in range(int(input()))), 2)))