Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.Scanner; public class Main { // Source @SuppressWarnings("unused") private static final String url = "http://codeforces.com/problemset/problem/437/A"; // variables private static String[] des; private static int[] length; private static int index1 = -1; private static ...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
options = [] options.append(("A", len(input()[2:]))) options.append(("B", len(input()[2:]))) options.append(("C", len(input()[2:]))) options.append(("D", len(input()[2:]))) options.sort(key=lambda x: x[1]) greatcount = 0 great = "C" if options[0][1]*2 <= options[1][1]: great = options[0][0] greatcount += 1 if opti...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> int ans = -1; char s[4][105]; int strlen(char x[]) { for (int i = 0;; i++) if (!x[i]) return i; } int main() { scanf("A.%[^\n]\n", s[0]); scanf("B.%[^\n]\n", s[1]); scanf("C.%[^\n]\n", s[2]); scanf("D.%[^\n]\n", s[3]); for (int i = 0; i < 4; i++) { int sh = 0, lo = 0; fo...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { vector<string> v(4); for (int i = 0; i < 4; ++i) cin >> v[i]; vector<bool> flag(4, false); for (int i = 0; i < 4; ++i) { bool temp1 = true, temp2 = true; for (int j = 0; j < 4; ++j) { if (i != j) { if (!(v[i].size() - 2 >= 2 * (v[j...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import static java.lang.Math.*; import java.math.*; import java.text.DecimalFormat; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] a = new int[4]; String[] b = new String[4]; for (int i = 0; i < a.len...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c, d; cin >> a >> b >> c >> d; int ll[4]; ll[0] = a.length() - 2; ll[1] = b.length() - 2; ll[2] = c.length() - 2; ll[3] = d.length() - 2; int x[4][2] = {0}; int mini = 200, mn_i; for (int i = 0; i < 4; i++) { if (ll[i] < min...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner theScanner = new Scanner(System.in); String[] choices = new String[4]; ArrayList<Integer> lengths = new ArrayList<Integer>(); for(int i=0; i<4; i++){ ...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { char s[200]; int f[4], i, flag, j, c1, c2, tmp, flag1; while (scanf("%s", s) != EOF) { f[0] = strlen(s); f[0] -= 2; for (i = 1; i <= 3; i++) { scanf("%s", s); f[i] = strlen(s); f[i] -= 2; } flag = flag1 = 0; for (...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int i, j, k, n, max1, min1; char x, y; string s[1000]; for (i = 0; i < 4; i++) { cin >> s[i]; if (i == 0) { max1 = s[i].length(); x = s[i][0]; min1 = s[i].length(); y = s[i][0]; } else { if (s[i].length() > max1...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws IOException { FastScanner scan = new FastScanner(); PrintWriter out = new PrintWriter(System.ou...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner x=new Scanner (System.in); int arr[]=new int [4]; for(int i=0;i<4;i++){ String str=x.next(); arr[i]=str.length()-2; } int f=0; int mmm...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = sorted([ (len(raw_input()) - 2, i) for i in range(4) ]) b, s = a[0][0] * 2 <= a[1][0], a[2][0] * 2 <= a[3][0] print 'C' if not b^s else chr(a[s*3][1] + 65)
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, k, l; string str[4], s[4]; for (i = 0; i < 4; i++) { cin >> str[i]; n = str[i].size(); s[i] = ""; for (j = 2; j < n; j++) { s[i] += str[i][j]; } } bool flag = 0; set<int> ans; for (i = 0; i < 4; i++) { fl...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int arr1[4]; int arr2[4]; string str; bool test1 = false; bool test2 = false; int count = 0; int count2 = 0; for (int i = 0; i < 4; i++) { cin >> str; arr1[i] = str.size() - 2; arr2[i] = str.size() - 2; } sort(arr2, arr2 + 4); ...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#! /usr/bin/env python a = len(input()[2:]) b = len(input()[2:]) c = len(input()[2:]) d = len(input()[2:]) arr = [a, b, c, d] candi = [] for i, x in enumerate(arr): sf = True bf = True for j, y in enumerate(arr): if i != j: if x > y / 2: sf = False if x < y...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = [0] * 4 for i in range(4): s = input().strip() a[i] = len(s) - 2 ans = 'C' f = 0 for i in range(4): f1 = 1 f2 = 1 for j in range(4): if i != j and a[i] < 2 * a[j]: f1 = 0 if i != j and 2 * a[i] > a[j]: f2 = 0 if f1 : ans = chr(ord("A") + i) ...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
quests = sorted([ raw_input() for i in xrange(4) ], key = lambda x : len(x)-2) predicts = [] if len(quests[3])-2 >= 2*(len(quests[2])-2) : predicts += quests[3][0] if 2*(len(quests[0])-2) <= len(quests[1])-2 : predicts += quests[0][0] print predicts[0] if len(predicts)==1 else 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = input()[2:] b = input()[2:] c = input()[2:] d = input()[2:] # print(a,'\n',b,'\n',c,'\n',d) answer = "" if (len(a)*2 <= len(b) and len(a)*2 <= len(c) and len(a)*2 <= len(d)) or (len(a) >= len(b)*2 and len(a) >= len(c)*2 and len(a) >= len(d)*2): answer += 'A' if (len(b)*2 <= len(a) and len(b)*2 <= len(c) and len...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a=len(input()) b=len(input()) c=len(input()) d=len(input()) a-=2 b-=2 c-=2 d-=2 count=0 if a>= 2*(max(b,c,d)) or a<=(min(b,c,d)//2): count+=1 f='A' if b>= 2*(max(a,c,d)) or b<=(min(a,c,d)//2): count+=1 f="B" if c>= 2*(max(b,a,d)) or c<=(min(b,a,d)//2): count+=1 f="C" i...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] a = new int[4]; for (int i = 0; i < 4; i++) { a[i] = in.next().length() - 2; } char ans = 0, ansNum = 0; for (int i = 0; i < 4; i++) { int j = (i + 1) % 4; int k = (i + 2...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { char a[5][110]; while (scanf("%s", a[1]) != EOF) { scanf("%s", a[2]); scanf("%s", a[3]); scanf("%s", a[4]); int len[5]; for (int i = 1; i <= 4; i++) { len[i] = strlen(a[i]) - 2; } int mark1 = 0, flag1 = 0, cor; for (int...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; char a[150], b[150], c[150], d[150]; bool aa, bb, cc, dd; int main(void) { cin >> a >> b >> c >> d; int len_a = strlen(a) - 2, len_b = strlen(b) - 2, len_c = strlen(c) - 2, len_d = strlen(d) - 2; if (len_a * 2 <= len_b && len_a * 2 <= len_c && len_a * 2 <= len_d...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.*; public class A437 { public static void main(String[] args) { Scanner in = new Scanner(System.in); String a = in.nextLine(); String b = in.nextLine(); String c = in.nextLine(); String d = in.nextLine(); int res=0; int[] st = new int[4]; st[0] = a.length()-2; st[1] = b.length()-2; ...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = input() b = input() c = input() d = input() arr = [0] * 4 s = "ABCD" arr[0] = len(a) - 2 arr[1] = len(b) - 2 arr[2] = len(c) - 2 arr[3] = len(d) - 2 ans = "" bigcnt = 0 for i in range(4): cnt = 0 for j in range(4): if i != j and (arr[j] * 2 <= arr[i]): cnt += 1 elif i != j and (arr[j] >= ar...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { pair<int, char> a[10]; string s; cin >> s; a[1].first = s.size() - 2; a[1].second = s[0]; cin >> s; a[2].first = s.size() - 2; a[2].second = s[0]; cin >> s; a[3].first = s.size() - 2; a[3].second = s[0]; cin >> s; a[4].first = s.size()...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { bool smaller = 1, bigger = 1; short int small_index = 0, big_index = 0; string choices[4]; cin >> choices[0]; choices[0].erase(0, 2); int biggest = choices[0].size(), smallest = choices[0].size(); for (int i = 1; i < 4; i++) { cin >> choices[i...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.*; import java.math.*; public class glava{ public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = 4; int arr[] = new int[4]; for (int i=0;i<4;i++) { arr[i] = in.next().length() - 2; } int[] copy = arr.clone(...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
s = sorted([(len(raw_input()) - 2, i) for i in range(0, 4)]) x, y = s[0][0] * 2 <= s[1][0], s[2][0] * 2 <= s[3][0] print 'C' if not x ^ y else chr(s[y * 3][1] + 65)
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int s[]=new int [4]; for (int i = 0; i < s.length; i++) { s[i]=sc.next().length()-2; } boolean used[]=new boolean [4]; boolean f=true; for (int i = 1; i < s.length; i++) { if(s[0]*2>s[i])...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; long long m, n, i, j, k, d, x, a, b; string s[4]; vector<long long> v; int main() { cin >> s[0] >> s[1] >> s[2] >> s[3]; for (i = 0; i < 4; i++) { m = 0; n = 0; for (j = 0; j < 4; j++) { if (i != j) { if ((s[i].size() - 2) >= 2 * (s[j].size() -...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
list = {} list['A'] =len(raw_input(""))-2 list['B'] =len(raw_input(""))-2 list['C'] =len(raw_input(""))-2 list['D'] =len(raw_input(""))-2 v=sorted(list.values()) if v[3]/v[2] >= 2 : if v[1]/v[0] >= 2 : print 'C' else : for i in list : if list[i] == v[3] : ...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
l=sorted([(len(raw_input())-2, chr(i+ord('A'))) for i in xrange(4)]) a=l[0][0]*2<=l[1][0] b=l[2][0]*2<=l[3][0] if a^b: if l[0][0]*2<=l[1][0]: print l[0][1] else: print l[3][1] else: print 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = [[]] * 4 for i in xrange(4): a[i] = len(raw_input()[2:]) cnt = 0 res = None mp = ['A', 'B', 'C', 'D'] for i in xrange(4): shorter, longer = 0, 0 for j in xrange(4): if j != i and a[i] >= 2 * a[j]: longer += 1 if j != i and a[i] * 2 <= a[j]: shorter += 1 if shorter == 3 or longer == 3: ...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = [] a.append(input()) a.append(input()) a.append(input()) a.append(input()) b = [] for i in range(len(a)): b.append(len(a[i]) - 2) b.sort() res = [] if b[0] * 2 <= b[1] and b[1] != 0: res.append(b[0]) if b[2] * 2 <= b[3] and b[3] != 0: res.append(b[3]) if len(res) == 1: for i in range(l...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import math def solve(str): if str[1][0] >= str[0][0] * 2 and str[3][0] >= (str[2][0] * 2): print 'C' return if str[1][0] >= str[0][0] * 2: print str[0][1] return if str[3][0] >= (str[2][0] * 2): print str[3][1] return print 'C' if __name__ == "__ma...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#!/usr/bin/python def read_one(): s = raw_input() return s[2:] s = [read_one(), read_one(), read_one(), read_one()] s = [len(e) for e in s] r = 'ABCD' s = [(e, c) for e, c in zip(s, r)] s.sort() if 2*s[0][0]<=s[1][0]: zero_good = True else: zero_good = False if s[3][0]>=2*s[2][0]: last_good =...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; long long ABS(long long x) { if (x < 0) return -x; return x; } long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return b / gcd(a, b) * a; } string x[4]; int len[4]; bool big(int idx) { fo...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main{ public static void main(String[]args)throws IOException{ BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); String s=""; int[]l=new int[4]; for(int i=0;i<4;i++){ s=bf.r...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
len_lst = [] for i in range(4): option = input().strip() len_lst.append(len(option) - 2) sort_lst = sorted(len_lst) great = 0 if sort_lst[1] >= 2 * sort_lst[0]: great += 1 key = sort_lst[0] if sort_lst[3] >= 2 * sort_lst[2]: great -= 1 key = sort_lst[3] dic = {len_lst[0]: 'A', len_lst[1]: 'B', l...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = input() b = input() c = input() d = input() arr = [len(a)-2,len(b)-2,len(c)-2,len(d)-2] ak = min(arr) am = max(arr) flag,flag2=0,0 for i in range(4): if 2*ak<=arr[i]: flag+=1 if am>=2*arr[i]: flag2+=1 if flag2>=3 and flag<3: print(chr(arr.index(am)+65)) elif flag>=3 and flag2<3: print(chr(arr.index(ak)+65))...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#!/bin/python2 import sys def compare_slen(x,y): return cmp(len(x),len(y)) class Solution: def qs_partition(self,li,start,end,compare): j = start - 1 if compare == None: compare = cmp for i in range(start,end): if compare(li[i],li[end]) <= 0: j...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
def suM(cca): su = "" for j in range(len(cca)): su+=cca[j] return su ans = [] a = input().split('.') b = input().split('.') c = input().split('.') d = input().split('.') #check = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ca = a[1].split('_');cb = b[1].split('_'); cc = c[1].split('_'...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a=map(lambda s:len(s)-2,(raw_input() for _ in range(4))) b=sorted(a) c=[] if b[0]*2<=b[1]: c+=[a.index(b[0])] if b[-1]>=b[-2]*2: c+=[a.index(b[-1])] print 'ABCD'[c[0]] if 1==len(c) else 'C'
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.*; import java.math.*; import java.lang.*; public class main{ static void bubbleSort(String[] arr) { int n = arr.length; String temp; for(int i=0; i < n; i++){ for(int j=1; j < (n-i); j++){ if(arr[j-1].length() > arr[j].length()...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
options = [] great = [0]*4 for line in range(4): options.append(input().split(".")) for i in range(4): options2 = options[:] y = options2.pop(i) short = True for o in options2: if len(y[1]) <= len(o[1])/2: pass else: short = False break larg...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
s1=[] a1=[] a2=[] for index in range (4): s1.append(raw_input()) a1.append(0) a2.append(0) for index1 in range (len (s1)): for index2 in range(len(s1)): if index1!=index2: if len(s1[index1])-2>=(len(s1[index2])-2)*2: a1[index1]+=1 elif (len(s1[index1])-2)...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
# while True: # try: # # n = int(raw_input()) # except (EOFError): # break # b = map(int, s2.split()) s = [] m = [] ans = ['A', 'B', 'C', 'D'] for i in xrange(4): temp = len(raw_input()) - 2 s.append(temp) m.append(temp) m.sort() great1 = True for i in xrange(1, 4): if m[i] < 2 *...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a=[] for _ in range(4): a.append(len(raw_input())-2) b = sorted(a) se, le = False, False if b[0] <= b[1] / 2: se = True if b[3] / 2 >= b[2]: le = True if se == le: print "C" else: if se: print "ABCD"[a.index(b[0])] else: print "ABCD"[a.index(b[3])]
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a=['0']*4 b=[""]*4 c=[0]*4 for i in range(4): a[i],b[i]=map(str,input().split('.')) c[i]=len(b[i]) c=sorted(c) x=0 if(c[0]*2<=c[1]): x=1 if(c[2]*2<=c[3]): if(x==0): x=2 else: x=0 if(x==1): for i in range(4): if(len(b[i])==c[0]): print(a[i]) break e...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; void online_judge() {} const int N = 2e5 + 5; int small = INT_MIN; int large = INT_MAX; void solve() { string s1, s2, s3, s4; cin >> s1 >> s2 >> s3 >> s4; vector<pair<int, char>> a; a.push_back(make_pair(s1.size() - 2, 'A')); a.push_back(make_pair(s2.size() - 2, '...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
def func(l): x=0 k=2 for i in range(4): p = [int(not 2*l[i]<=l[j]) for j in range(4) if i!=j] f = [int(2*l[j]<=l[i]) for j in range(4) if i!=j] if p==f and len(list(dict.fromkeys(f)))==1: x+=1 k=i if x==1: return chr(ord('A')+k) return 'C' a,b,c,d = len(input())-2,len(input())-2,len(input())-2,len(in...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import sys la = len(sys.stdin.readline().strip()) - 2 lb = len(sys.stdin.readline().strip()) - 2 lc = len(sys.stdin.readline().strip()) - 2 ld = len(sys.stdin.readline().strip()) - 2 def isgreat(x): x = x - 1 orig = [la, lb, lc, ld] l = [la, lb, lc, ld] l.sort() if (orig[x] <= l[1]/2): re...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class ChildHomework { private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { System.out.println(getRightChoice(loadAnswers(4))); } private static String getRightChoice(List<Answer> an...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string s[4]; char ans = 'C'; bool exist = false; for (int i = 0; i < 4; i++) cin >> s[i]; for (int i = 0; i < 4; i++) { bool great = true; for (int j = 0; j < 4; j++) if (i != j) if (s[i].length() - 2 < 2 * (s[j].length() - 2)) g...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.*; import java.io.*; public class Main{ BufferedReader in; StringTokenizer str = null; PrintWriter out; private String next() throws Exception{ while (str == null || !str.hasMoreElements()) str = new StringTokenizer(in.readLine()); return str.nextToken(); } ...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
from sys import stdin __author__ = 'artyom' def read_next_line(): tokens = stdin.readline().strip().split('.') return [tokens[0], len(tokens[1])] ls = list(map(lambda _: read_next_line(), range(4))) accepted = [x for x in ls if all(t[0] == x[0] or t[1] / x[1] >= 2 for t in ls) or a...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int p = 0; char ch = '0', var; pair<int, char> sam[4]; string str[4]; for (int i = 0; i < 4; i++) { cin >> str[i]; sam[i].first = str[i].size() - 2; sam[i].second = (char)65 + i; } sort(sam, sam + 4); if (sam[0].first <= sam[1].first...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.Scanner; public class TukkaMar { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String[] option = new String[4]; int[] length = new int[4]; for (int i = 0; i < 4; i++){ option[i] = scanner.nextLine(); len...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a=[] k=[] for i in range(4): a.append(input()) def fun(num): b=a.index(num) a.remove(num) r=all(len(num)-2>=2*(len(i)-2) for i in a) a.insert(b,num) if r==True: return num else:return None for i in a: k.append(fun(i)) def fun1(num1): b=a.index(num1) a.remove(num1) r ...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; /** * @author grozhd */ public class HomeWork { static int[] ans; public static void main(String[] args) { read(); String[] letters = {"A", "B", "C", "D"}; int numberOfGood = 0; int goodIndex = 0; for...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
/* right answer: - description is 2x the next largest OR description is 1/2x the next smallers - sort by length - check first and last - or, keep max and max-mult and min and min mult - walk choices - checking to see if current is > mac or < min. - if so, update and indicate the delta as a percentage - check at e...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = len(input())-2 b = len(input())-2 c = len(input())-2 d = len(input())-2 ans = "" if (a >= 2*b and a >= 2*c and a >= 2*d) or (2*a <= b and 2*a <= c and 2*a <= d): ans += "A" if (b >= 2*a and b >= 2*c and b >= 2*d) or (2*b <= a and 2*b <= c and 2*b <= d): ans += "B" if (c >= 2*b and c >= 2*d and c >= 2*a) or (2*c <...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] s = new String[4]; int[] l = new int[4]; for (int i = 0; i < 4; ++i) s[i] = sc.nextLine(); for (int i = 0; i < 4; ++i) l[i] = s[i].length()...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a=len(input())-2 b=len(input())-2 c=len(input())-2 d=len(input())-2 g = [a,b,c,d] h = [a,b,c,d] minPresent = False maxPresent = False g.sort() if g[0]*2 <= g[1]: minPresent = True if g[3] >= g[2]*2: maxPresent = True toPrint = ['A','B','C','D'] if minPresent and (not maxPresent) : print(toPrint[h.index...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.io.*; public class CF437A { static boolean great(int a, int b, int c, int d) { return a >= b + b && a >= c + c && a >= d + d || a + a <= b && a + a <= c && a + a <= d; } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.io.*; import java.math.*; import java.util.*; public class SolutionA { public static void main(String[] args){ new SolutionA().run(); } int n, m; int a[]; String b[]; void solve(){ a = new int[4]; b = new String[4]; for(int i = 0; i < 4; i++){ b[i] = in.next(); a[i] = b[i].length()-2; ...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.List; import java.util.StringTokenizer; /** * Created by fangxue.zhang on 2014/6/1. */ public class CF_250_div2 { public static void main(String[...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = [] for _ in range(4): s = input() a.append((len(s[2:]),s[0])) a.sort() flag1 = 0 flag2 = 0 if a[0][0] <= a[1][0]//2: flag1 =1 if a[3][0] >= a[2][0]*2: flag2 = 1 if flag1 and flag2: print("C") elif flag1: print(a[0][1]) elif flag2: print(a[3][1]) else: print("C")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
tab = {0: 'A', 1: 'B', 2: 'C', 3: 'D'} so = [] for i in range(4): so.append(raw_input()) for i in range(4): so[i] = so[i][2:] # for i in range(4): # print so[i] ans = [] for i in range(4): cnt = 0 for j in range(4): if i!=j and (len(so[i]) >= 2*len(so[j])): cnt += 1 if cnt...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
lenList=[0]*4 for i in range(4): x=input() lenList[i]=(len(x)-2, chr(ord('A')+i)) lenList.sort() if lenList[0][0]*2 <= lenList[1][0] and lenList[3][0] < 2*lenList[2][0]: print(lenList[0][1]) elif lenList[3][0] >= 2*lenList[2][0] and lenList[0][0]*2 > lenList[1][0]: print(lenList[3][1]) else: print("C")
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.PrintWriter; import java.util.StringTokenizer; // Note that at the actual CodeForces cont...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
choice=[0,0,0,0] string=' ' ans=65 Max,Min=0,1000 maxi,mini=0,0 for i in range(4) : string=raw_input(); choice[i]=len(string)-2 if choice[i]>Max : Max=choice[i] maxi=i if choice[i]<Min : Min=choice[i] mini=i l,s=True,True for i in range(4) : if maxi!=i and (choice[maxi]/choice[i])<2: l=False if mini!=i...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { std::cerr << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); std::cerr...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
a = len(input())-2 b = len(input())-2 c = len(input())-2 d = len(input())-2 l = list() l.append(a) l.append(b) l.append(c) l.append(d) l = sorted(l) x,y = 0, 0 if l[0] <= l[1]//2 and l[0] <= l[2]//2 and l[0] <= l[3]//2: x = 1 if l[3] >= l[0]*2 and l[3] >= l[1]*2 and l[3] >= l[2]*2: y = 1 if x+y == 1: if x =...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
A = len(input()[2:]) B = len(input()[2:]) C = len(input()[2:]) D = len(input()[2:]) answer = 'C' counter = 0 if ( all(A >= e*2 for e in [B, C, D]) or all(A <= (e//2) for e in [B, C, D]) ): answer = 'A' counter += 1 if ( all(B >= e*2 for e in [A, C, D]) or all(B <= (e//2) for e in [A, C, D]) ): a...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
# -*- coding:utf-8 -*- import sys def some_func(): """ """ a = raw_input() b = raw_input() c = raw_input() d = raw_input() lit=[len(a)-2,len(b)-2,len(c)-2,len(d)-2] dic = {'A':len(a)-2, 'B':len(b)-2, 'C':len(c)-2, 'D':len(d)-2, } lit.sort() if lit[0]*2<=lit[1] and lit[3] <lit...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
op=[] ans=['A','B','C','D'] for i in range(4): op.append(raw_input()) length=[] for s in op: length.append(len(s)-2) m=max(length) M=length.index(m) n=min(length) N=length.index(n) c=0 d=0 for i in range(4): if i!=M and length[i]<=m/2: c+=1 for i in range(4): if i!=N and length[i]>=2*n: ...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.*; public class TheChildAndHomework { public static void main(String[] args) { InputStream inputStream = Syste...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.util.Scanner; public class A437 { public static void main(String[] args) { Scanner nn = new Scanner(System.in); String s1 = nn.nextLine(); String s2 = nn.nextLine(); String s3 = nn.nextLine(); String s4 = nn.nextLine(); int n1 = s1.length() - 2; ...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
fun=lambda:len(raw_input())-2 data=[fun() for i in xrange(4)] ans=['A','B','C','D'] flag=0 index=0 for i in xrange(4): tmp1=0 tmp2=0 for j in xrange(4): if i==j: continue if data[i] * 2 <= data[j]: tmp1+=1 if data[i] >= data[j] * 2: tmp2+=1 if ...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> int main() { char s[5][1007]; int a[5]; for (int i = 1; i <= 4; i++) { gets(s[i]); a[i] = strlen(s[i]) - 2; } int count1, count2; int t; int z = 0; for (int i = 1; i <= 4; i++) { count1 = count2 = 0; for (int j = 1; j <= 4; j++) { if ((a[i] - a[j] * 2) >= 0...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class MultipleChoice { static StringTokenizer st; st...
JAVA
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
''' * Author : Ayushman Chahar # * About : IT Sophomore # * Insti : VIT, Vellore # ''' import os import sys # from collections import * # from itertools import * # from math import * # from queue import * # from heapq import * # from bisect import * from io import BytesIO, IOBase BUFSIZE = 8192 class Fast...
PYTHON3
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c, d; cin >> a >> b >> c >> d; string ans = ""; int A = a.length() - 2, C = c.length() - 2, B = b.length() - 2, D = d.length() - 2; if ((A <= (B / 2) && A <= (C / 2) && A <= (D / 2)) || ((A / 2) >= (B) && (A / 2) >= (C) && (A ...
CPP
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
import sys answers = [] for line in sys.stdin: answers.append(len(line)-3) #print answers final_answer = "C" maxLen = minLen = answers[0] uniqueMin = True uniqueMax = True for answer in answers[1:]: if answer >= maxLen: if answer == maxLen: uniqueMax = False else: maxLen = answer uniqueMa...
PYTHON
437_A. The Child and Homework
Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct. Fortunately the child knows how to solve such complicated test. The chi...
2
7
#include <bits/stdc++.h> using namespace std; bool comparator(pair<int, char> p1, pair<int, char> p2) { return p1.first < p2.first; } int main() { string a, b, c, d; cin >> a >> b >> c >> d; vector<pair<int, char>> v; v.push_back(make_pair(a.length() - 2, 'A')); v.push_back(make_pair(b.length() - 2, 'B')); ...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:20000000") int n; char s[200005]; int a[200005]; bool v[200005]; int l[200005], r[200005]; priority_queue<pair<int, pair<int, int> > > q; vector<pair<int, int> > res; int main() { scanf("%d\n", &n); gets(s); for (int i = 0; i < (n); ++i...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; int n, s[200001]; char g[200001]; set<pair<int, pair<int, int> > > S; vector<pair<int, int> > ans; int l[200001], r[200001]; void run() { cin >> n >> g; for (int i = 0; i < n; i++) { cin >> s[i]; l[i] = r[i] = -1; } S.clear(); ans.clear(); for (int i = 0...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
import javax.swing.*; import java.io.*; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import java.util.Map.Entry; public class Main implements Runnable { static final int MOD = (int) 1e9 + 7; static final int MI = (int) 1e9; stati...
JAVA
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
from heapq import heapify,heappush,heappop n = int(input()) sex = input() a = [int(i) for i in input().split()] cp = [] r = [] b = sex.count('B') N = min(n-b,b) for i in range(1,len(a)): if sex[i] != sex[i-1]: cp.append((abs(a[i]-a[i-1]),i-1,i)) heapify(cp) prev = [i for i in range(-1,len(sex))] nxt = [i f...
PYTHON3
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; struct guy { int skill, indice; char g; guy *next, *prev; guy() { skill = indice = 0; next = prev = NULL; } }; const int MAXN = 2e5 + 100; guy guys[MAXN]; bool visited[MAXN]; class compare { public: bool operator()(const pair<int, int> &p1, const pair<i...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; struct node { int b, g; int dis; node(int _b, int _g, int _dis) { b = _b; g = _g; dis = _dis; } bool operator<(node bb) const { if (dis != bb.dis) return dis > bb.dis; return b > bb.b; } }; char str[200020]; int a[200020]; bool vis[200020]; i...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; const int NN = 200000 + 8; int N, Pre[NN], Nxt[NN], Idx[NN]; int Val[NN]; char is[NN]; int head, tail; int iabs(int v) { return v < 0 ? -v : v; } int main(int argc, char *argv[]) { scanf("%d", &N); scanf("%s", is + 1); for (int i = 1; i <= N; ++i) { scanf("%d", Va...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; set<pair<int, pair<int, int> > > S; int A[200005]; set<int> X; int main() { ios::sync_with_stdio(0); int n; cin >> n; string s; cin >> s; s = " " + s; for (int i = 1; i <= n; ++i) { cin >> A[i]; X.insert(i); } X.insert(0); X.insert(n + 1); for ...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; static const double EPS = 1e-12; struct parson { int id; int skill; char gender; bool operator<(const struct parson &a) const { return id < a.id; } }; struct parsonPair { int diff; int id0; int id1; bool operator<(const struct parsonPair &a) const { if (...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 100; struct node { int index, skill; bool G; node *prev, *next; node() { prev = next = NULL; index = skill = G = 0; } }; node *add[MAXN]; struct comp { bool operator()(const pair<int, int> &a, const pair<int, int> &b) { int da ...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-9; const long long INF = 100000000000000000; const int MAXN = 3 * 100000; struct T { int left, right, diff; bool operator<(const T& other) const { if (diff != other.diff) return diff > other.diff; return left >...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; int a[2200000], i, n, t1, t2, k; string aux; multiset<int>::iterator first, second; pair<int, int> auxt, ans[2200000]; int mod(int a) { if (a < 0) return -a; return a; } struct fcomp { bool operator()(pair<int, int> first, pair<int, int> second) { if (mod(a[first....
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5, inf = 1e9 + 7; set<pair<int, pair<int, int> > > st; int lft[N], rgt[N], vis[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { if (i == 1) lft[i] = -1; else lft[i...
CPP
45_C. Dancing Lessons
There are n people taking dancing lessons. Every person is characterized by his/her dancing skill ai. At the beginning of the lesson they line up from left to right. While there is at least one couple of a boy and a girl in the line, the following process is repeated: the boy and girl who stand next to each other, havi...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 300000; int n, i, x, y; int l[N], r[N], a[N]; char s[N]; vector<pair<int, int> > ans; struct atom { int l, r, p; }; atom t; bool d[N]; inline bool operator<(const atom& a, const atom& b) { return (a.p < b.p || (a.p == b.p && a.l < b.l)); } multiset<atom> q...
CPP