prompt string | response string |
|---|---|
Problem: Chef wants to hire a new assistant. He published an advertisement regarding that in a newspaper. After seeing the advertisement, many candidates have applied for the job. Now chef wants to shortlist people for the interviews, so he gave all of them one problem which they must solve in order to get shortlisted.... | for t in xrange(int(raw_input())):
n = int(raw_input())
i = 1
s = 0
while (i*i<=n):
if (n%i==0):
temp = n/i
if (i != temp):
s += (i+temp)
else:
s += i
i += 1
print s |
Problem: Chef wants to hire a new assistant. He published an advertisement regarding that in a newspaper. After seeing the advertisement, many candidates have applied for the job. Now chef wants to shortlist people for the interviews, so he gave all of them one problem which they must solve in order to get shortlisted.... | m = input()
def factorsNum(n):
return set(reduce(list.__add__,
([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
for i in range(m):
r = int(raw_input())
if r == 1:
print 1
else:
print sum(factorsNum(r)) |
Problem: Chef wants to hire a new assistant. He published an advertisement regarding that in a newspaper. After seeing the advertisement, many candidates have applied for the job. Now chef wants to shortlist people for the interviews, so he gave all of them one problem which they must solve in order to get shortlisted.... | def solve(n):
i=1
ans=0
while i*i<=n:
if(n%i==0):
ans+=i
if(n/i!=i):
ans+=(n/i)
i+=1
return ans
def main():
test=int(input())
while test>0:
test-=1
n=int(input())
print solve(n)
main() |
Problem: This summer, there is a worldwide competition being held in Chef Town and some of the best chefs of the world are participating. The rules of this competition are quite simple.
Each participant needs to bring his or her best dish. The judges will initially assign a score to each of the dishes. Now, several r... | #!/usr/bin/env python
import sys
parent = None
#child = dict()
def find_set(x):
global parent
while parent[x] != x:
parent[x] = parent[parent[x]]
x = parent[x]
return parent[x]
T = int(sys.stdin.readline())
while T > 0:
N = int(sys.stdin.readline())
S = map(int, sys.std... |
Problem: This summer, there is a worldwide competition being held in Chef Town and some of the best chefs of the world are participating. The rules of this competition are quite simple.
Each participant needs to bring his or her best dish. The judges will initially assign a score to each of the dishes. Now, several r... | #!/usr/bin/env python
import sys
P = None
#child = dict()
def find_set(d):
global P
while P[d] != d:
P[d] = P[P[d]]
d = P[d]
return P[d]
T = int(sys.stdin.readline())
while T > 0:
N = int(sys.stdin.readline())
S = map(int, sys.stdin.readline().strip().split())
P = r... |
Problem: This summer, there is a worldwide competition being held in Chef Town and some of the best chefs of the world are participating. The rules of this competition are quite simple.
Each participant needs to bring his or her best dish. The judges will initially assign a score to each of the dishes. Now, several r... | import sys
# scans a line for integers
def scan_integers_in_line():
return map(int, sys.stdin.readline().split())
#global set DS
set_ac = []
# union set DS (union function)
def merge_set_ac(root1, root2):
global set_ac
set_ac[root2] = root1
# union set DS (find function)
def find_root_set_ac (root):
... |
Problem: This summer, there is a worldwide competition being held in Chef Town and some of the best chefs of the world are participating. The rules of this competition are quite simple.
Each participant needs to bring his or her best dish. The judges will initially assign a score to each of the dishes. Now, several r... | #!/usr/bin/env python
import sys
def find_set(P,d):
while P[d] != d:
P[d] = P[P[d]]
d = P[d]
return P[d]
T = int(sys.stdin.readline())
while T > 0:
N = int(sys.stdin.readline())
S = map(int, sys.stdin.readline().strip().split())
P = range(1,N + 1)
P = [-1] + P
... |
Problem: This summer, there is a worldwide competition being held in Chef Town and some of the best chefs of the world are participating. The rules of this competition are quite simple.
Each participant needs to bring his or her best dish. The judges will initially assign a score to each of the dishes. Now, several r... | '''p=[0]*10001
for i in range(10001):
p[i]=i
'''
p=None
def find(x):
global p
while p[int(x)]!=x:
p[x]=p[p[x]]
x=p[x]
return p[x]
import sys
t=int(raw_input())
for _ in range(t):
n=int(raw_input())
S=map(int,sys.stdin.readline().rstrip().split(' '))
p=range(n)
q=int(raw_i... |
Problem: This summer, there is a worldwide competition being held in Chef Town and some of the best chefs of the world are participating. The rules of this competition are quite simple.
Each participant needs to bring his or her best dish. The judges will initially assign a score to each of the dishes. Now, several r... | #!/usr/bin/env python
import sys
parent = None
#child = dict()
def find_set(x):
global parent
while parent[x] != x:
parent[x] = parent[parent[x]]
x = parent[x]
return parent[x]
if __name__=='__main__':
t = int(sys.stdin.readline())
while t > 0:
t -= 1
n = int... |
Problem: This summer, there is a worldwide competition being held in Chef Town and some of the best chefs of the world are participating. The rules of this competition are quite simple.
Each participant needs to bring his or her best dish. The judges will initially assign a score to each of the dishes. Now, several r... | #!/usr/bin/env python
import sys
parent = None
#child = dict()
def find_set(x):
global parent
while parent[x] != x:
parent[x] = parent[parent[x]]
x = parent[x]
return parent[x]
t = int(sys.stdin.readline())
while t > 0:
t -= 1
n = int(sys.stdin.readline())
si = map(int, s... |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | # cook your code here
n,k=map(int,raw_input().split())
count=0
for i in range(0,n):
if (int(raw_input()))%k==0:
count+=1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | a,b=raw_input().split()
count=0
arr=list()
a=int(a)
b=int(b)
for i in range(a):
n=raw_input()
arr.append(int(n))
for i in range(a):
if arr[i] % b == 0:
count=count+1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | a, b = map(int, raw_input().split())
d=0
for i in range(int(a)):
c=int(input())
if c%int(b)==0:
d+=1
else:
pass
print d |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | #!/usr/bin/python
n,k=raw_input().split()
n=int(n)
k=int(k)
sum=0
for i in range(0,n):
t=int(input())
if(t%k==0):
sum+=1
print sum |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n, k = map(int, raw_input().split(" "))
count = 0
for i in range(n):
element = input()
if element%k == 0:
count += 1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | # @author Kilari Teja
# INTEST
Params = map(int, raw_input().strip().split(" "))
K = Params[1]
Div = 0
for Indx in xrange(Params[0]):
if int(raw_input().strip())%K == 0:
Div += 1
print Div |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n, t = map(int,raw_input().strip().split(' '))
count = 0
for i in range(n):
x = raw_input().strip()
x = int(x)
if x % t == 0:
count += 1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | from sys import stdin
def readIO():
x = stdin.readline()
x = x.split()
n = int(x[0])
k = int(x[1])
num = 0
for _dummy in range(n):
r = int(stdin.readline())
if (r > 0) and ((r % k) == 0):
num += 1
return num
print readIO() |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n,k=map(int,raw_input().split())
count=0
while n:
n-=1
p=int(raw_input())
if p%k==0:
count+=1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n,k = raw_input().split()
n = int(n)
k = int(k)
t = []
div_count = 0
x = 0
for i in range(n):
x = input()
t.insert(i,x)
if t[i] % k == 0:
div_count += 1
print div_count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n,k=map(int,raw_input().split())
values=list()
count=0
for number in range(n):
values.append(int(raw_input()))
for item in values:
if (item%k)==0:
count=count+1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n, k=raw_input().split()
n=int(n)
k=int(k)
s=0
for a in range(0,n):
Ti=input()
if(Ti%k==0):
s=s+1
print s |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | #!/usr/bin/python
n, k = map(int, raw_input().strip().split(" "))
count = 0
for i in range(n):
element = int(raw_input())
if element%k == 0:
count += 1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | r=map(int,(raw_input().split()))
counter=0
for i in range(0,r[0]):
ch=int(raw_input())
if ch%r[1]==0:
counter +=1
print(counter) |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n, k = map(int, raw_input().strip().split())
count = 0
for i in range(n):
element = input()
if element%k == 0:
count += 1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | a, b=map(int,raw_input().split())
s=0
for i in range(a):
h=int(raw_input())
if h%b==0:
s+=1
print s |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n, k = map(int, raw_input().strip().split(" "))
count = 0
for i in xrange(n):
element = input()
if element%k == 0:
count += 1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | a, b=map(int,raw_input().split())
s=0
for i in range(a):
h=input()
if h%b==0:
s+=1
print s |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n, k = map(int, raw_input().split())
c = 0
while n>0:
t = int(raw_input())
if t%k == 0:
c += 1
n -= 1
print c |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | a=map(int,raw_input().split())
count=0
for i in range(0,a[0]):
b=input()
if b%a[1]==0:
count+=1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | def main():
w=(raw_input())
w=w.split(' ')
n=int(w[0])
k=int(w[1])
count=0
for i in range(n):
t=int(input())
if(t%k ==0):
count+=1
print(count)
main() |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | a=raw_input().split()
c=0
for i in range(int(a[0])):
b=input()
if b%int(a[1])==0:
c+=1
print c |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | import sys
line = sys.stdin.readline().split()
n = int(line [0])
k = int(line [1])
count = 0
while (n>0):
num = input()
if(num%k)==0:
count = count+1
n = n-1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | line=raw_input().split();
n=int(line[0]);
k=int(line[1]);
i=1
s=0
while(i<=n):
t=int(raw_input());
if(t%k==0):
s=s+1
i=i+1
print s |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n,k = map(int, raw_input().split())
count = 0
for i in range(0,n):
x = input()
if x%k==0:
count+=1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | st=raw_input()
L=st.split(' ')
n=int(L[0])
k=int(L[1])
s=0
for i in range(n):
t=input()
if t%k==0:
s+=1
print s |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | import sys
n,k = map(int,sys.stdin.readline().split())
c=0
for i in range(n):
m = int(raw_input())
if m % k == 0:
c +=1
print(c) |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | l = map(int,raw_input().split(' '))
n = l[0]
k = l[1]
ctr = 0
while n!=0:
ent = int(raw_input())
if ent%k==0:
ctr+=1
n-=1
print ctr |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | ques=str(raw_input(''))
ques=ques.split(' ')
a=int(ques[0])
b=int(ques[1])
ans=0
for i in range(0,a):
n=input('')
if n%b==0:
ans+=1
print ans |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | #!/usr/bin/python
import sys
n,k=sys.stdin.readline().split()
n=int(n)
k=int(k)
sum=0
for i in range(0,n):
t=int(input())
if(t%k==0):
sum+=1
print sum |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | #testing an already existing solution
count = 0
n,k = map(int,raw_input().split())
for i in range(n):
t = int(raw_input())
if t%k == 0:
count+= 1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n,m = raw_input().split()
out = 0
for i in range(int(n)):
k = raw_input()
if(int(k)%int(m) == 0):
out += 1
print out |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | L=raw_input().split()
cnt=0
k=int(L[1])
for i in range (int(L[0])):
n=input()
if n%k==0:
cnt+=1
print cnt |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n,k = map(int,raw_input().split())
num = 0
for i in range(n):
t= int(raw_input())
if t%k==0:
num += 1
print num |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | # python3
if __name__ == "__main__":
n,k = map(int,raw_input().split())
i = 0
count = 0
while(i < n):
ch = int(raw_input())
i = i + 1
if(ch % k == 0 and k <= 10**7 and ch <= 10**9):
count = count + 1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | def method():
n,k = map(int, raw_input().split())
count = 0
for i in xrange(n):
num = int(raw_input())
if num%k==0:
count+=1
print count
method() |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | input1=raw_input()
input2=input1.split()
n=int(input2[0])
k=int(input2[1])
t=0
for i in range(n):
a=int(raw_input())
if a%k==0:
t=t+1
print t |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | a,b = raw_input().split()
count=0
for x in xrange(int(a)):
in1 = int(raw_input())
if in1%int(b)==0:
count +=1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | def readInput():
counter=0
var1=raw_input()
numbers=var1.split(" ")
inputTaken=[]
num1=int(numbers[0])
num2=int(numbers[1])
for i in range(0,num1):
var2=int(raw_input())
inputTaken.append(var2)
for num in inputTaken:
if(num%num2==0):
counter+=1
print counter
readInput() |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n, k=map(int, raw_input().split())
no_list=[]
for iteration in range(n):
no_list.append(int(raw_input()))
count=0
for no in no_list:
if no%k==0:
count+=1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n, k = raw_input().split()
n = int(n)
k = int(k)
div = 0
for i in range(n):
inp = int(raw_input())
if inp % k == 0:
div += 1
print div |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | n, k = map(int, raw_input().split())
count = 0
for i in range(0, n):
x = int(raw_input())
r = x % k
if r == 0:
count = count + 1
print count |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | x,y=raw_input().split()
x=int(x)
y=int(y)
c=0
for i in range(0,x):
n=input()
if(n%y==0):
c +=1
print c |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | lines, divisor = map(int, raw_input().split())
no_divisible = 0
for _ in range(0, lines):
if (int(raw_input())%divisor)==0:
no_divisible = no_divisible+1
print no_divisible |
Problem: The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two posit... | #!/usr/bin/python
import sys
n,k=sys.stdin.readline().split()
n=int(n)
k=int(k)
sum=0
for i in range(0,n):
t=int(raw_input())
if(t%k==0):
sum+=1
print sum |
Problem: At the function of Republic day at NIT Agartala the warden of hostel has to visit the ground and
check the arrangement of the chairs for guests.
In the ground of NIT Agartala all the chairs are arranged in N rows and M columns.
Warden has to check that in each row all the chairs must have same color and adjac... | # your code goes here
m,n = map(int,raw_input().split())
a = []
for _ in range(m):
a.append(map(int,raw_input().split()))
flag = 1
for i in range(m):
for j in range(n):
if j > 0:
if a[i][j-1] != a[i][j]:
flag = 0
break
if i > 0:
if a[i-1][j] == a[i][j]:
flag = 0
break
if flag == 0:
br... |
Problem: Sereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M parts. Probability that a player numbered i wins part j of any set is p[i]... | from operator import mul
parse = lambda: [25*i for i in map(float, raw_input().split())]
for _ in xrange(int(raw_input())):
n, m = map(int, raw_input().split())
num = reduce(mul, parse())
den = num
for _ in xrange(n - 1):
den += reduce(mul, parse())
if num == 0:
den = 1
print '%.6f' % (num/den) |
Problem: Sereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M parts. Probability that a player numbered i wins part j of any set is p[i]... | from operator import mul
parse = lambda: [26*i for i in map(float, raw_input().split())]
for _ in xrange(int(raw_input())):
n, m = map(int, raw_input().split())
num = reduce(mul, parse())
den = num
for _ in xrange(n - 1):
den += reduce(mul, parse())
if num == 0:
den = 1
print '%.6f' % (num/den) |
Problem: Sereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M parts. Probability that a player numbered i wins part j of any set is p[i]... | import math
for _ in xrange(input()):
n, m = map(int, raw_input().split())
total = float(1.0)
sereja_probs = map(float, raw_input().split())
done = False
for i in sereja_probs:
if i == 0.0:
print "0.000000"
done = True
break
for i in xrange(1,... |
Problem: Sereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M parts. Probability that a player numbered i wins part j of any set is p[i]... | import decimal
for tc in range(int(raw_input())):
N, M = map(int, raw_input().split())
deno = 0
for n in range(N):
product = decimal.Decimal('1.0')
for p in map(decimal.Decimal, raw_input().split()): product *= p
if n == 0: num = product
deno += product
... |
Problem: Sereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M parts. Probability that a player numbered i wins part j of any set is p[i]... | from operator import mul
from decimal import Decimal
for _ in xrange(int(raw_input())):
n, m = map(int, raw_input().split())
num = reduce(mul, map(Decimal, raw_input().split()), Decimal(1))
den = num
for i in xrange(n - 1):
den += reduce(mul, map(Decimal, raw_input().split()), Decimal(1))
if den == 0:
print '0... |
Problem: Sereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M parts. Probability that a player numbered i wins part j of any set is p[i]... | import decimal
def product(a, s, e):
m = decimal.Decimal(1)
for i in xrange(s, e + 1):
m *= a[i];
return m
for t in range(1, input() + 1):
[n, m] = [int(x) for x in raw_input().split()]
p1 = decimal.Decimal(0)
p1n = decimal.Decimal(0)
for i in xrange(0, n):
a = [decimal.Decim... |
Problem: Sereja is playing a game called Winner Eats Sandwich with his friends. There are N persons in total, including Sereja. Sereja is allotted the number 1, while his friends are allotted numbers from 2 to N. A set of this game consists of M parts. Probability that a player numbered i wins part j of any set is p[i]... | import sys, decimal
raw_input = sys.stdin.readline
for tc in range(int(raw_input())):
N, M = map(int, raw_input().split())
deno = 0
for n in range(N):
product = decimal.Decimal('1.0')
for p in map(decimal.Decimal, raw_input().split()): product *= p
if n == 0: num = product
... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
int n, m;
int a[500005], vis[500005], nx[500005];
struct nod {
int r, id;
};
vector<nod> enq[500005];
int ans[500005];
int mx[2000005], pos[2000005];
void jia(int now, int l, int r, int ai, int v) {
if (l == r) {
mx[now] = v;
pos[now] = l;
return;
}
int ... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v);
template <typename A, typename B>
ostream& operator<<(ostream& cout, pair<A, B> const& p) {
return cout << "(" << p.first << ", " << p.second << ")";
}
template <typ... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
inline char nc() {
static char buf[100000], *p1 = buf, *p2 = buf;
return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
? EOF
: *p1++;
}
inline void read(int &x) {
char c = nc(), b = 1;
for (; !(c >= '0' && c <= '9')... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
const int inf = 0x7fffffff;
int n, m;
int a[500010] = {0}, mx = -1, nxt[500010] = {0};
int p[500010] = {0};
struct Segtree {
int l, r;
int mxi;
} t[2000010];
inline int lson(int x) { return x << 1; }
inline int rson(int x) { return x << 1 | 1; }
void maketree(int x, int l, int r) {
if (l ... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int64_t M1 = 998244353;
const int64_t M2 = 1000000007;
int64_t l[500001];
int64_t r[500001];
int64_t cnt[500001];
int64_t a[500001];
int64_t ans[500001];
int64_t mark[500001];
int64_t query[500001];
vector<int64_t> b;
int64_t len;
bool comp(int64_t i, int64_t j) {
i... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | import java.io.*;
import java.util.*;
public class A {
public static void main (String[] args) { new A(); }
int[] b;
int oo = (int)1e9;
public A() {
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
System.err.println("");
int n = fs.nextInt();
int[] a = fs.nextIntArr... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const static int SZ = 700;
bool cmp(tuple<int, int, int> a, tuple<int, int, int> b) {
if (get<0>(a) / SZ != get<0>(b) / SZ) return get<0>(a) / SZ < get<0>(b) / SZ;
return get<0>(a) / SZ % 2 ? get<1>(a) > get<1>(b) : get<1>(a) < get<1>(b);
}
tuple<int, int, int> query[50... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int Z = (int)3e3 + 228;
const int N = (int)5e5 + 5;
const int INF = (int)1e9 + 228;
const int MOD = (int)998244353;
const long long LLINF = (long long)1e18 + 228;
const long double eps = (long double)1e-6;
int a[N], cnt[N], ans[N], val[N];
int n, sq, cur;
vector<int> ... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
return x * f;
}
inline char char_read() {
char ch = getch... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 1000;
const long long INF64 = (long long)1e18 + 1000;
const int N = (int)1e6 + 1000;
const int MOD = (int)1e9 + 7;
const int K = 800;
vector<int> cnt(N);
vector<int> bl(K);
vector<int> can(N);
int cnt_pret = 0;
void add(int x) {
++cnt[x];
if (... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.function.BiFunction;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.uti... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | import java.math.*;
import java.util.*;
import java.io.*;
public class Main {
class Node {
int id;
int r;
public Node(int id,int r){
this.id=id;
this.r=r;
}
}
void solve(){
int n=ni();
a=new int[n+1];
int cnt[]=new int[500001];
for(int i=1;i<=n;i++)... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int Inf = 1e9;
vector<pair<int, int> > q[500010];
int n, qn, A[500010], pre[500010], lst[500010], Ans[500010];
pair<int, int> T[500010 * 4];
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
char B[1 << 15], *S = B, *T = B;
inline long long read() {
long long x = 0, f = 1;
char ch =
(S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF
: *S++);
while (!isdigit(ch)) {... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | import java.io.*;
import java.math.*;
import java.util.*;
public class Program {
public static class Reader {
private final int BUFFER_SIZE = 1 << 12;
private int LENGTH = -1;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
struct Node {
int L, R, id;
} b[500005];
struct Tree {
int L, R;
pair<int, int> val;
} T[2000005];
int a[500005], pre[500005], nxt[500005], h[500005], ans[500005];
inline void Modify(int L, int R, pair<int, int> val, int v) {
if (L > T[v].R || R < T[v].L) return;
... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import javafx.util.Pair;
public class Solve7 {
public static void mai... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int block = 710;
int n, m, a[1000000], bo[1000000], top, sta[1000000], pos[1000000],
ans[1000000];
struct arr {
int l, r, num;
} ask[1000000];
bool cmp(arr x, arr y) {
if ((x.l - 1) / block == (y.l - 1) / block) {
if (((x.l - 1) / block) & 1) return x.r > ... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 2;
int Next[N], Prev[N];
int in[N];
int queryRet[N];
int L[N], R[N];
pair<int, int> seg[N * 4];
void update(int pos, int l, int r, int ind, int val) {
if (l == r) {
seg[pos] = make_pair(val, ind);
return;
}
int mid = (l + r) / 2;
if (ind ... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
struct query {
int l, r, id;
};
int n, m, x, y, sq, curl, curr;
int a[500005], ans[500005];
int check[500005], cnt[500005];
query q[500005];
bool cmp(query a, query b) {
if (a.l / sq != b.l / sq) {
return a.l / sq < b.l / sq;
} else {
if ((a.l / sq) & 1) {
... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
long long ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1) ret = (ret * p) % M;
p = (p * p) % M;
}
return (T)ret;
}
template <cla... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
inline long long rd() {
long long x = 0;
char c = getchar();
int neg = 1;
while (c < '0' || c > '9') {
if (c == '-') neg = -1;
c = getchar();
}
while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * neg;... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0;
char c = getchar();
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x;
}
const int maxn = 5e5 + 10;
int n, m, blo, a[maxn];
struct Query {
int l, r, id;
bool oper... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Str... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
const long long N = 500500;
const long long Q = 2e18;
const long long mod = 998244353;
const long long MAGIC = 30;
using namespace std;
int n;
int a[N];
int l[N];
int r[N];
int ans[N];
int used[N];
pair<int, int> t[4 * N];
void upd(int x, int l, int r, int g, int y) {
if (l == r) {
t[x] =... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
template <class T>
void show(const vector<T> &a) {
for (T x : a) cout << x << " ";
cout << endl;
}
const int N = 5e5 + 9;
const int oo = 1e9;
int a[N];
int nx[N];
int n;
int t[N << 2];
void upd(int v, int tl, int tr, int pos) {
t[v] = ... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
long long int dx[] = {0, 1, 0, -1, -1, 1, -1, 1};
long long int dy[] = {-1, 0, 1, 0, -1, 1, 1, -1};
const long long int MAXN = 5e5 + 5;
const long long int N = 1e6 + 5;
long long int n, m;
long long int BLOCK = 555;
struct query {
long long int l, r, i;
inline bool oper... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int N = 500 * 1000 + 13;
const int INF = 1e9;
pair<pair<int, int>, int> t[4 * N];
void build(int v, int l, int r) {
if (l == r - 1) {
t[v] = make_pair(make_pair(INF, INF), l);
return;
}
int m = (l + r) / 2;
build(v * 2, l, m);
build(v * 2 + 1, m, r);... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 9;
int a[N], Q[N][3], ord[N], answer[N], frq[N], Inside[N], n, q;
deque<int> dq;
inline void Push(int x) {
if (!Inside[x]) dq.push_front(x);
Inside[x] = 1;
}
inline void add(int idx) {
if (++frq[a[idx]] == 1) {
Push(a[idx]);
}
}
inline void r... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int Max = 500500;
int n, a[Max], q, cnt[Max], outp[Max], belong[Max];
char vis[Max];
vector<int> ans;
struct node {
int l, r, id;
} que[Max];
int cmp(const node& a, const node& b) {
if (belong[a.l] == belong[b.l]) {
if (belong[a.l] & 1) {
return belong[a... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int base = 19260817;
const int INF = 1e9;
const int maxn = 2e5 + 10;
const double eps = 1e-8;
int add(int x, int y) {
x += y;
return x >= mod ? x - mod : x;
}
int sub(int x, int y) {
x -= y;
return x < 0 ? x + mod : x;
}
int mul(int ... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
pair<int, pair<int, int> > ar[500010], tree[22][500010];
pair<int, int> moa[22][500010];
int n, pre[500010], nex[500010], val[500010];
void mergeIt(int b, int e, int l, int r, int lev) {
int x = b, y = r;
for (int p = b; b <= e || l <= r; p++) {
if (b > e || (tree[l... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
int n, m, i, j, b, a[500005], l = 1, r, cnt[500005];
bool in[500005];
vector<int> s;
struct query {
int l, r, ans, id;
} q[500005];
bool cmp(const query &x, const query &y) {
if (x.l / b < y.l / b) return 1;
if (x.l / b > y.l / b) return 0;
return ((x.l / b) & 1) ? ... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
class seg_extremum {
public:
vector<T> arr;
int size, n;
T inf;
const bool is_max;
seg_extremum(int m, T value, bool is_max) : is_max(is_max) {
n = 1;
while (n < m) n *= 2;
size = n * 2;
arr.resize(size);
fill(arr.begin()... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | #include <bits/stdc++.h>
using namespace std;
ifstream in;
ofstream out;
const long long kk = 1000;
const long long ml = kk * kk;
const long long mod = ml * kk + 7;
const long long inf = ml * ml * ml + 7;
vector<long long> t;
long long n, i, j, q, s, nex_r;
vector<long long> m, ans;
vector<pair<pair<long long, long lon... |
Problem: You are given an array a consisting of n integers, and q queries to it. i-th query is denoted by two integers l_i and r_i. For each query, you have to find any integer that occurs exactly once in the subarray of a from index l_i to index r_i (a subarray is a contiguous subsegment of an array). For example, if ... | import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
new Main().solve();
}
BufferedReader reader;
BufferedWriter writer;
StringTokenizer st;
public Main() {
reader = new BufferedReader(new Input... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.