Created
March 11, 2012 03:25
-
-
Save soopercorp/2014867 to your computer and use it in GitHub Desktop.
drchrono-codesprint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def atoi(a): | |
return ord(a)-65 | |
""" | |
def itoa(a): | |
return chr(a+65) | |
""" | |
i = 0 | |
ip = [] | |
NUM_AL = 26 | |
while i < NUM_AL: | |
l = raw_input() | |
ip.append(l.rstrip().split(' ')) | |
i+=1 | |
for i in ip: | |
i.pop(0) | |
# [['asd'], ['asd', 'sad']] | |
num = raw_input() | |
num = int(num) | |
inter = [] | |
i=0 | |
while i < num: | |
l = raw_input() | |
inter.append(l.rstrip().split(' ')) | |
i+=1 | |
#[['A0','B1'],['A1','B0']] | |
for el in inter: | |
#['A0','B1'] | |
toinform = [] | |
for el2 in el: | |
if el2[1] == '1': | |
for eli in ip[atoi(el2[0])]: | |
toinform.append(eli) | |
print ' '.join(sorted(set(toinform))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter your code here. Read input from STDIN. Print output to STDOUT | |
from collections import Counter | |
arr_size = raw_input() | |
arr = [] | |
for a in range(0,int(arr_size)): | |
n = raw_input() | |
arr.append(int(n)) | |
quer = raw_input() | |
qarr = [] | |
for a in range(0,int(quer)): | |
n = raw_input() | |
qarr.append(n) | |
for i,el in enumerate(qarr): | |
qarr[i] = el.split(' ') | |
qarr[i][0] = int(qarr[i][0])-1 | |
qarr[i][1] = int(qarr[i][1])-1 | |
start = qarr[i][0] | |
end = qarr[i][1] | |
y=Counter(arr[start:end+1]) | |
for k,v in y.items(): | |
if(y[k]>1): | |
del y[k] | |
out = len(y) | |
#out = len(set(arr[start:end+1])) | |
print out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment