output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s446458537
Runtime Error
p03288
Input is given from Standard Input in the following format: R
R = int(input()) if R < 1200: print('ABC') else if R < 2800: print('ARC') else: print('AGC')
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s221100415
Runtime Error
p03288
Input is given from Standard Input in the following format: R
R = int(input()) if R < 1200: r = 'ABC' elif R < 2800: r = 'ARC': else: r ='AGC' print(r)
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s897586861
Runtime Error
p03288
Input is given from Standard Input in the following format: R
R = int(input()) if R < 1200: print('ABC') elif <2800: print('ARC') else: print('AGC')
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s237510687
Runtime Error
p03288
Input is given from Standard Input in the following format: R
n=int(input()) if(n<1200): print("ABC") elif(n<2800): print("ARC"): elif(n>=2800): print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s732865779
Runtime Error
p03288
Input is given from Standard Input in the following format: R
n=int(input()) if n < 1200: print("ABC") elif n<2800: print("ARC") else:print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s965594880
Runtime Error
p03288
Input is given from Standard Input in the following format: R
R = int(input()) if R < 1200: print("ABC") eif R < 2800: print("ARC") else: print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s266548243
Wrong Answer
p03288
Input is given from Standard Input in the following format: R
b = int(input().rstrip()) if b < 1200: a = "ABC" elif b < 2800 & b > 1199: a = "ARC" else: a = "AGC" print(a)
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s692966765
Runtime Error
p03288
Input is given from Standard Input in the following format: R
function Main(input) { input = input.split("\n"); var r = parseInt(input[0].split(" ")[0]); var ans = "AGC"; if(r<1200){ ans = "ABC"; }else if(r<2800){ ans = "ARC"; } console.log('%s', ans); } Main(require("fs").readFileSync("/dev/stdin", "utf8"));
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s845120284
Runtime Error
p03288
Input is given from Standard Input in the following format: R
inp = int(input()) if inp < 1200: print("ABC") else if 1200 <= inp && inp < 2800: print("ARC") else: print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s758542041
Runtime Error
p03288
Input is given from Standard Input in the following format: R
my_rate = input() if my_rate < 1200: print("ABC") elif my rate >=1200 and my_rate < 2800: print("ARC") else: print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s780754467
Runtime Error
p03288
Input is given from Standard Input in the following format: R
#-*-coding:utf-8-*- def main(): r = int(input()) if r < 2000: print('ABC') elif r >= 1200 ans r < 2800: print('ARC') else: print('AGC') if __name__ == '__main__': main()
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s946180909
Runtime Error
p03288
Input is given from Standard Input in the following format: R
R = int(input()) if R < 1200: print("ABC") else: if R < 2800: print("ARC") else: print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s550551220
Runtime Error
p03288
Input is given from Standard Input in the following format: R
n = int(input()) ans = "" if n < 1200: ans = "ABC" else if n < 2800: ans = "ARC" else: ans = "AGC" print(ans)
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s259648912
Runtime Error
p03288
Input is given from Standard Input in the following format: R
s = input() mod = 10**9 + 7 abc = 0 bc = 0 c = 0 q = 0 for i in s[::-1]: elif i == "A": abc = (abc + bc) % mod elif i == "B": bc = (bc + c) % mod elif i == "C": c = (3**q+c) % mod elif i == "?": abc = (abc*3 + bc) % mod bc = (bc*3 + c) % mod c = (3**q + c*3) % mod q += 1 print(abc)
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s755983120
Runtime Error
p03288
Input is given from Standard Input in the following format: R
inp = int(input()) if inp < 1200: print("ABC") else if 1200 <= inp && inp < 2800: print("ARC") else: print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s574982989
Runtime Error
p03288
Input is given from Standard Input in the following format: R
n=input() if n <1200 print("ABC") elif n<2800 print("ARC") lese print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s014833825
Runtime Error
p03288
Input is given from Standard Input in the following format: R
a=int(input()) if a<1200: print("ABC") else if a<2800: print("ARC") else: print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s738829145
Runtime Error
p03288
Input is given from Standard Input in the following format: R
a = input() if a < 1200: print("ABC") else if a < 2800: print("ARC") else: print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s367068068
Wrong Answer
p03288
Input is given from Standard Input in the following format: R
print("ABC" if int(input()) < 1200 else "ARC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s388693342
Runtime Error
p03288
Input is given from Standard Input in the following format: R
C = ["ABC", "ARC" , "AGC"] A = int(input()) print(C[(A>1200)+(A>2800)]
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s788649381
Runtime Error
p03288
Input is given from Standard Input in the following format: R
n = int(nput()) print("ABC" if n < 1200 else "ARC" if 1200 <= n < 2800 else "AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s268645098
Runtime Error
p03288
Input is given from Standard Input in the following format: R
R = int(input()) if R < 1200: print("ABC") elif R < 2800: print("ARC") else print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s205988096
Runtime Error
p03288
Input is given from Standard Input in the following format: R
n = int(input()) if n<1200: print("ABC") elif: n<2800: print("ARC") else: print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s068711293
Runtime Error
p03288
Input is given from Standard Input in the following format: R
R = int(input()) if R<1200:
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s712772236
Runtime Error
p03288
Input is given from Standard Input in the following format: R
n=int(input()) print('ABC') if n<1200 else if n<2800 print('ARC') else print('AGC')
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s284962760
Runtime Error
p03288
Input is given from Standard Input in the following format: R
l = input() if l<1200: print("ABC") elif l<2800 print("ARC") else : print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s922985525
Runtime Error
p03288
Input is given from Standard Input in the following format: R
r = int(input());print("ABC"if r<1200else"ARC"if else r<2800else"AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`). * * *
s833194122
Runtime Error
p03288
Input is given from Standard Input in the following format: R
R=int(input()) if R <1200 print("ABC") if R<2800 print("ARC") else print("AGC")
Statement A programming competition site _AtCode_ regularly holds programming contests. The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200. The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800. The contest after the ARC is called AGC, which is rated for all contestants. Takahashi's rating on AtCode is R. What is the next contest rated for him?
[{"input": "1199", "output": "ABC\n \n\n1199 is less than 1200, so ABC will be rated.\n\n* * *"}, {"input": "1200", "output": "ARC\n \n\n1200 is not less than 1200 and ABC will be unrated, but it is less than 2800\nand ARC will be rated.\n\n* * *"}, {"input": "4208", "output": "AGC"}]
If S is a concatenation of two copies of some string, print `Yes`; otherwise, print `No`. * * *
s610691053
Wrong Answer
p02860
Input is given from Standard Input in the following format: N S
data_len = int(input()) data = input() if data[0 : int(data_len / 2)] == data[int(data_len / 2) : data_len]: print("true") else: print("false")
Statement Given are a positive integer N and a string S of length N consisting of lowercase English letters. Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.
[{"input": "6\n abcabc", "output": "Yes\n \n\nLet T = `abc`, and S = T + T.\n\n* * *"}, {"input": "6\n abcadc", "output": "No\n \n\n* * *"}, {"input": "1\n z", "output": "No"}]
If S is a concatenation of two copies of some string, print `Yes`; otherwise, print `No`. * * *
s190160834
Accepted
p02860
Input is given from Standard Input in the following format: N S
N, S = open(0).read().split() # print(N, S) n = int(int(N) / 2) print("Yes" if S[:n] == S[n:] else "No")
Statement Given are a positive integer N and a string S of length N consisting of lowercase English letters. Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.
[{"input": "6\n abcabc", "output": "Yes\n \n\nLet T = `abc`, and S = T + T.\n\n* * *"}, {"input": "6\n abcadc", "output": "No\n \n\n* * *"}, {"input": "1\n z", "output": "No"}]
If S is a concatenation of two copies of some string, print `Yes`; otherwise, print `No`. * * *
s909205448
Wrong Answer
p02860
Input is given from Standard Input in the following format: N S
I = [input() for i in range(2)] sn = int(I[0]) ss = str(I[1]) if sn % 2 == 1: A = "No" else: sl = int(sn / 2) H1 = ss[1:sl] H2 = ss[sl + 1 :] if H1 == H2: A = "Yes" else: A = "No" print(A)
Statement Given are a positive integer N and a string S of length N consisting of lowercase English letters. Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.
[{"input": "6\n abcabc", "output": "Yes\n \n\nLet T = `abc`, and S = T + T.\n\n* * *"}, {"input": "6\n abcadc", "output": "No\n \n\n* * *"}, {"input": "1\n z", "output": "No"}]
If S is a concatenation of two copies of some string, print `Yes`; otherwise, print `No`. * * *
s207001659
Wrong Answer
p02860
Input is given from Standard Input in the following format: N S
r = int(input()) print(r**2)
Statement Given are a positive integer N and a string S of length N consisting of lowercase English letters. Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.
[{"input": "6\n abcabc", "output": "Yes\n \n\nLet T = `abc`, and S = T + T.\n\n* * *"}, {"input": "6\n abcadc", "output": "No\n \n\n* * *"}, {"input": "1\n z", "output": "No"}]
If S is a concatenation of two copies of some string, print `Yes`; otherwise, print `No`. * * *
s435671594
Wrong Answer
p02860
Input is given from Standard Input in the following format: N S
_, s = open(0) print("YNeos"[s[: len(s) // 2] * 2 != s :: 2])
Statement Given are a positive integer N and a string S of length N consisting of lowercase English letters. Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.
[{"input": "6\n abcabc", "output": "Yes\n \n\nLet T = `abc`, and S = T + T.\n\n* * *"}, {"input": "6\n abcadc", "output": "No\n \n\n* * *"}, {"input": "1\n z", "output": "No"}]
If S is a concatenation of two copies of some string, print `Yes`; otherwise, print `No`. * * *
s226733296
Wrong Answer
p02860
Input is given from Standard Input in the following format: N S
print("Yes")
Statement Given are a positive integer N and a string S of length N consisting of lowercase English letters. Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.
[{"input": "6\n abcabc", "output": "Yes\n \n\nLet T = `abc`, and S = T + T.\n\n* * *"}, {"input": "6\n abcadc", "output": "No\n \n\n* * *"}, {"input": "1\n z", "output": "No"}]
If S is a concatenation of two copies of some string, print `Yes`; otherwise, print `No`. * * *
s876244021
Runtime Error
p02860
Input is given from Standard Input in the following format: N S
n, s = input().split()
Statement Given are a positive integer N and a string S of length N consisting of lowercase English letters. Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.
[{"input": "6\n abcabc", "output": "Yes\n \n\nLet T = `abc`, and S = T + T.\n\n* * *"}, {"input": "6\n abcadc", "output": "No\n \n\n* * *"}, {"input": "1\n z", "output": "No"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s366022193
Accepted
p03267
Input is given from Standard Input in the following format: L
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1, ran2) def rand_List(ran1, ran2, rantime): return [random.randint(ran1, ran2) for i in range(rantime)] def rand_ints_nodup(ran1, ran2, rantime): ns = [] while len(ns) < rantime: n = random.randint(ran1, ran2) if not n in ns: ns.append(n) return sorted(ns) def rand_query(ran1, ran2, rantime): r_query = [] while len(r_query) < rantime: n_q = rand_ints_nodup(ran1, ran2, 2) if not n_q in r_query: r_query.append(n_q) return sorted(r_query) from collections import defaultdict, deque, Counter from sys import exit from decimal import * import heapq from math import sqrt, pi from fractions import gcd import random import string import copy from itertools import combinations, permutations, product from operator import mul, itemgetter from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10**9 + 7 ############# # Main Code # ############# L = int(input()) Lstr = bin(L)[2:] N = len(Lstr) M = (N - 1) * 2 + (Lstr.count("1") - 1) print(N, M) c = 1 for i in range(1, N): print(i, i + 1, c) print(i, i + 1, 0) c *= 2 c = 2 ** (N - 1) for i, v in enumerate(Lstr[::-1]): if i == N - 1: continue if v == "1": print(i + 1, N, c) c += 2**i
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s795858793
Wrong Answer
p03267
Input is given from Standard Input in the following format: L
# coding: utf-8 # https://atcoder.jp/contests/abc108 # -15:48 done def main(): L = int(input()) N = len(str(L)) + 1 for i in range(1, 7): if L == 10**i: N = len(str(L)) M = 10 * (N - 1) print("{} {}".format(N, M)) for s in range(1, N): for j in range(10): print("{} {} {}".format(s, s + 1, j * (10 ** (s - 1)))) return None if L < 10: M = L print("{} {}".format(N, M)) for i in range(L): print("{} {} {}".format(1, 2, i)) return None rest = int("".join(str(L)[1:])) base = L - rest head = int(str(L)[0]) M = (N - 2) * 10 + head + rest print("{} {}".format(N, M)) for s in range(1, N - 1): for i in range(10): print("{} {} {}".format(s, s + 1, i * (10 ** (s - 1)))) for i in range(head): print("{} {} {}".format(N - 1, N, i * (10 ** (N - 2)))) for r in range(rest): print("{} {} {}".format(1, N, base + r)) main() # print(main())
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s437791587
Runtime Error
p03267
Input is given from Standard Input in the following format: L
L = bin(int(input()))[2:] L = L.zfill((~-len(L) // 4 + 1) * 4) node = ["1"] + [L[i * 4 : i * 4 + 4] for i in range(len(L) // 4)] + ["1"] for i in range(len(node) - 1): for s, x in enumerate(node[i]): for t, y in enumerate(node[i + 1]): if x == "1" and y == "1": print(s + i * 4 + 2, t + i * 4 + 6, 2 ** (si * 4 + 2))
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s061433831
Wrong Answer
p03267
Input is given from Standard Input in the following format: L
import sys l = int(input()) ansl = [] rest = l ansl.append((1, 2, 1)) rest -= 1 now = 1 for i in range(2, l): now *= 2 for j in range(i): if rest == 0: print(str(ansl[-1][1]) + " " + str(len(ansl))) for a, b, c in ansl: print(str(a) + " " + str(b) + " " + str(c)) sys.exit() if i - j == 1: if l // 2 >= now: ansl.append((j + 1, i + 1, now)) rest -= now // 2 else: if l // 2 >= now: ansl.append((j + 1, i + 1, (now // 2) * 3)) rest -= 1 else: ansl.append((j + 1, i + 1, now)) rest -= 1 print(str(ansl[-1][1]) + " " + str(len(ansl))) for a, b, c in ansl: print(str(a) + " " + str(b) + " " + str(c))
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s541640425
Wrong Answer
p03267
Input is given from Standard Input in the following format: L
n = int(input()) - 1 if n < 10: print(2, n + 1) for i in range(n + 1): print(1, 2, i) elif n == 999999: edge = [] for i in range(6): k = n % 10 for j in range(k + 1): edge.append((i + 1, i + 2, j * (10**i))) n = n // 10 print(7, len(edge)) for u, v, w in edge: print(u, v, w) else: edge = [(1, 2, 0)] for i in range(6): a = n % 10 if n < 10: edge.append((max(1, i * 2), i * 2 + 2, a * (10**i))) for j in range(a): edge.append((i * 2 + 1, i * 2 + 2, j * (10**i))) point = i * 2 + 2 break else: for j in range(1, a + 1): edge.append((max(1, i * 2), i * 2 + 2, j * (10**i))) for j in range(a + 1, 10): edge.append((max(1, i * 2), i * 2 + 3, j * (10**i))) edge.append((i * 2 + 2, i * 2 + 3, 0)) n = n // 10 print(point, len(edge)) for u, v, w in edge: print(u, v, w)
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s446603592
Wrong Answer
p03267
Input is given from Standard Input in the following format: L
l = int(input()) n = l + 2 m = (n - 1) + (n - 2) print("{} {}".format(n, m)) for i in range(2, n + 1): print("1 {} 0".format(i)) for i in range(2, n): print("{} {} 1".format(i, i + 1))
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s642176671
Wrong Answer
p03267
Input is given from Standard Input in the following format: L
l = int(input()) lc = l lbit = [] goal = 0 while lc: lbit.append(lc % 2) lc //= 2 for i in range(len(lbit)): goal += lbit[i] * max(0, i - 1) goal += 2 if sum(lbit) >= 2: goal += 1 edge = [] def solve(length, shift): if length == 1: edge.append((1, goal, 0)) return if length == 2: edge.append((1, goal, 0)) edge.append((1, goal, 1)) return k = 0 while 2 ** (k + 1) <= length: k += 1 remain = length - 2**k for i in range(k): if i == 0: edge.append((1, shift + 2, 0)) edge.append((1, shift + 2, 1)) elif i == k - 1 and remain == 0: edge.append((i + shift + 1, goal, 0)) edge.append((i + shift + 1, goal, 2**i)) else: edge.append((i + shift + 1, i + shift + 2, 0)) edge.append((i + shift + 1, i + shift + 2, 2**i)) if remain: edge.append((k + shift + 1, goal, remain)) solve(remain, shift + k - 1) solve(l, 0) print(goal, len(edge)) for v1, v2, w in edge: print(v1, v2, w)
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s314268597
Accepted
p03267
Input is given from Standard Input in the following format: L
L = int(input()) l = 0 pp = 0 tmp = L while tmp > 0: l += 1 pp += tmp % 2 tmp //= 2 print(l, l * 2 - 3 + pp) for i in range(1, l): print(i, i + 1, 0) a = 1 << (i - 1) print(i, i + 1, a) if L & a: L -= a print(i, l, L)
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s761917788
Runtime Error
p03267
Input is given from Standard Input in the following format: L
n, k = map(int, input().split()) (*a,) = filter(lambda x: x % k == 0, range(1, n + 1)) if k % 2: print(len(a) ** 3) else: (*b,) = filter(lambda x: x % k == k // 2, range(1, n + 1)) print((len(a) ** 3) + (len(b) ** 3))
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s069857528
Runtime Error
p03267
Input is given from Standard Input in the following format: L
2 4 1 2 0 1 2 1 1 2 2 1 2 3
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s603724946
Runtime Error
p03267
Input is given from Standard Input in the following format: L
n = (int)(input()) l = (list)(map(int, input().split())) sorted(l) print(l[n // 2])
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s494924359
Wrong Answer
p03267
Input is given from Standard Input in the following format: L
l = int(input()) m = 1 p = 0 while m <= l: p += 1 m *= 2 m //= 2 l -= m way = [] for i in range(2, p + 1): way.append([i - 1, i, 0]) length = 1 c = 1 while c < p: way.append([c, c + 1, length]) length *= 2 c += 1 c = p - 1 while l != 0: m //= 2 c -= 1 if l // m == 0: continue l %= m way.append([1, p - c, length]) print(str(p) + " " + str(len(way))) for i in way: print(" ".join(list(map(str, i))))
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s839270071
Runtime Error
p03267
Input is given from Standard Input in the following format: L
k = int(input()) - 1 if k == 0: print(2, 1) print(1, 2, 0) else: def f(x, n): c = [] while x > 0: c.append(x % n) x = x // n return c io = 0 for i in range(2, 40): if io == 1: break else: c = f(k, i) d = 2 p = int(c[0]) + 1 for j in range(1, len(c)): h = int(c[j]) d += j * h p += i * j * h + h else: if d <= 20 and p <= 60: print(d, p) m = i io = 1 break po = 2 q = f(k, m) for n in range(0, q[0]): print(1, d, n) print(1, 2, q[0]) for s in range(1, len(q)): for i in range(0, q[s]): print(po, po + s, m**s) po += s g = 2 for s in range(1, len(q)): for t in range(0, q[s]): for o in range(0, s - 1): for l in range(0, m): print(g, g + 1, l * m**o) else: g += 1 else: for e in range(0, m): print(g, d, e * m ** (s - 1)) g += 1
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s746531343
Wrong Answer
p03267
Input is given from Standard Input in the following format: L
import sys class paiza_fmt_input: def __init__(self): self.cur = 0 self.all_input = [] def input_all(self): for line in sys.stdin: self.all_input.append(line) def get_one_line_with_split(self): input_cur = self.all_input[self.cur] self.cur += 1 splitted_input = input_cur.split() return splitted_input def get_bit_list(num): bit_list = [] for i in range(64): if (num >> i) & 1: bit_list.append(i) return bit_list def solve(inputs): line1_input = list(map(int, inputs.get_one_line_with_split())) path_num = line1_input[0] bit_list = get_bit_list(path_num) # print(bit_list) max_bit = bit_list[-1] # print(max_bit) dags = [] for i in range(max_bit): dags.append([i + 1, i + 2, 0]) dags.append([i + 1, i + 2, pow(2, i)]) # print(dags) end_node_no = bit_list[-1] + 2 bit_list.pop() ofs_num_cur = pow(2, max_bit) while True: if not bit_list: break bit = bit_list.pop() dags.append([bit + 1, end_node_no, ofs_num_cur]) ofs_num_cur += pow(2, bit) # print(dags) # output print(end_node_no, len(dags)) for dag in dags: print(*dag) inputs = paiza_fmt_input() inputs.input_all() solve(inputs)
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s938897945
Accepted
p03267
Input is given from Standard Input in the following format: L
def f(k, L, p): m = L while m % 3 > 0: p += [[k + 1, 20, (m - 1) * (3**k)]] m = m - 1 if m == 0: print(20, len(p)) for l in p: print(" ".join([str(t) for t in l])) quit() for i in range(3): p += [[k + 1, k + 2, i * (3**k)]] m = m // 3 if m > 0: return f(k + 1, m, p) f(0, int(input()), [])
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
In the first line, print N and M, the number of the vertices and edges in your graph. In the i-th of the following M lines, print three integers u_i,v_i and w_i, representing the starting vertex, the ending vertex and the length of the i-th edge. If there are multiple solutions, any of them will be accepted. * * *
s701311493
Wrong Answer
p03267
Input is given from Standard Input in the following format: L
# -*- coding: utf-8 -*- import math import sys import heapq from operator import itemgetter import itertools input = sys.stdin.readline # a = int(input().rstrip()) # a, b = map(int, input().rstrip().split()) # D = list(map(int, input().rstrip().split())) # H = [int(input().rstrip()) for _ in range(L)] # DD = [[0 for j in range(100)] for i in range(200)] # dict = {} ## dictionary # a = sorted(a, key=lambda x: x[1])) # if __name__ == '__main__': def get_n(l): if l == 2: return 2 elif l == 3: return 2 elif l == 4: return 2 else: for i in range(2, 21): if 2 ** (i - 1) <= l and l < 2**i: return i def get_arrows(n): ans = [[1, 2, 0], [1, 2, 1], [1, 2, 2], [1, 2, 3]] # 1 -> 2 の辺はデフォで入力 for i in range(2, n): ans.append([i, i + 1, 0]) ans.append([i, i + 1, 2**i]) return ans if __name__ == "__main__": L = int(input().rstrip()) n = get_n(L) a = get_arrows(n) print(n, len(a)) for p, q, r in a: print(p, q, r)
Statement You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number of edges, M, is at most 60. Each edge has an integer length between 0 and 10^6 (inclusive). * Every edge is directed from the vertex with the smaller ID to the vertex with the larger ID. That is, 1,2,...,N is one possible topological order of the vertices. * There are exactly L different paths from Vertex 1 to Vertex N. The lengths of these paths are all different, and they are integers between 0 and L-1. Here, the length of a path is the sum of the lengths of the edges contained in that path, and two paths are considered different when the sets of the edges contained in those paths are different.
[{"input": "4", "output": "8 10\n 1 2 0\n 2 3 0\n 3 4 0\n 1 5 0\n 2 6 0\n 3 7 0\n 4 8 0\n 5 6 1\n 6 7 1\n 7 8 1\n \n\nIn the graph represented by the sample output, there are four paths from\nVertex 1 to N=8:\n\n * 1 \u2192 2 \u2192 3 \u2192 4 \u2192 8 with length 0\n * 1 \u2192 2 \u2192 3 \u2192 7 \u2192 8 with length 1\n * 1 \u2192 2 \u2192 6 \u2192 7 \u2192 8 with length 2\n * 1 \u2192 5 \u2192 6 \u2192 7 \u2192 8 with length 3\n\nThere are other possible solutions.\n\n* * *"}, {"input": "5", "output": "5 7\n 1 2 0\n 2 3 1\n 3 4 0\n 4 5 0\n 2 4 0\n 1 3 3\n 3 5 1"}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s489130722
Runtime Error
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
import math n = int(input()) xy = [list(map(int, input().split())) for _ in range(n)] test_case = [] for x in (-1, 0, 1): for y in (-1, 0, 1): test_case.append((x, y)) for i in range(n): x1, y1 = xy[i] test_case.append((x1, y1)) test_case.append((-x1, -y1)) test_case.append((y1, -x1)) test_case.append((-y1, x1)) ret = 0 for x1, y1 in test_case: sx, sy, tx, ty = 0, 0, 0, 0 for j in range(n): x2, y2 = xy[j] if x1 * x2 + y1 * y2 > 0 or ( x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 >= 0 ): sx += x2 sy += y2 else: tx += x2 ty += y2 ret = max(ret, math.hypot(sx, sy), math.hypot(tx, ty)) print(ret)
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s914303188
Wrong Answer
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
for i in range(int(input())): print(10)
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s641239131
Wrong Answer
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
n = int(input()) for i in range(n): a = list(map(int, input().split()))
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s380216694
Runtime Error
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
import sys input = sys.stdin.readlinef from collections import deque n = int(input()) a = [[int(i) for i in input().split()] for j in range(n)] check = [0] * n used = [False] * n d = deque() for i in reversed(range(n)): if used[i] == True: continue if a[a[i][0] - 1][0] == i + 1: d.appendleft([i + 1, a[i][0]]) used[i] = True used[a[i][0] - 1] = True check[i] = 1 check[a[i][0] - 1] = 1 ans = 0 if len(d) == 0: print(-1) exit() # print(d) while len(d) > 0: used = [False] * n ans += 1 num = len(d) for i in range(num): tmp = d.popleft() for j in range(2): if check[tmp[j] - 1] == n - 1: continue psn = a[tmp[j] - 1][check[tmp[j] - 1]] - 1 mys = tmp[j] - 1 if check[mys] == n - 1 or check[psn] == n - 1: continue # print(tmp,psn,a[psn][check[psn]]) # print(i,j,tmp,psn,check[mys],check[psn]) if used[mys] == True or used[psn] == True: continue if a[psn][check[psn]] == mys + 1: d.append([psn + 1, mys + 1]) used[mys] = True used[psn] = True check[mys] += 1 check[psn] += 1 # print(d) for i in range(n): if check[i] != n - 1: print(-1) exit() print(ans)
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s036435117
Wrong Answer
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
n = int(input()) A = [] for _ in range(n): A.append(list(map(int, input().split()))) current_node = [0 for _ in range(n)] ongoing = [i for i in range(n)] days = 0 def get_matched(): matched = [] for i in range(n): i_current = current_node[i] if i_current >= n - 1: continue # print(i, i_current, len(A[i])) opponent = A[i][i_current] - 1 opponent_current = current_node[opponent] if i == A[opponent][opponent_current] - 1: matched.append([i, opponent]) return matched def proceed(matched): done = 0 for m in matched: current_node[m[0]] += 1 if current_node[m[0]] == n - 1: done += 1 ongoing.remove(m[0]) return done
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s715442277
Wrong Answer
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
print(input())
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s135234198
Accepted
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
N = int(input()) # 初期化 G = [[] for i in range(10**6 + 1)] # グラフ U = [None] * (10**6 + 1) # 入次数 D = [0] * (10**6 + 1) # 根からの距離 # 変換用 def x(i, j): return j + 1000 * i # グラフを構築 for i in range(1, N + 1): A = list(map(int, input().split())) for j in range(N - 2): fv1, fv2 = min(i, A[j]), max(i, A[j]) tv1, tv2 = min(i, A[j + 1]), max(i, A[j + 1]) G[x(fv1, fv2)].append(x(tv1, tv2)) U[x(fv1, fv2)] = 0 U[x(tv1, tv2)] = 0 # 入次数をカウント for i in range(10**6 + 1): for v in G[i]: U[v] += 1 # トポロジカルソート U_zero_nodes = [] for i in range(10**6 + 1): if U[i] is None: continue if U[i] == 0: U_zero_nodes.append(i) topological_order = [] while U_zero_nodes: n = U_zero_nodes.pop() topological_order.append(n) for v in G[n]: U[v] -= 1 if U[v] == 0: U_zero_nodes.append(v) # 不可能判定 if len(topological_order) != N * (N - 1) // 2: print(-1) exit() # 最長経路を計算 for t_n in topological_order: for v in G[t_n]: D[v] = max(D[v], D[t_n] + 1) print(max(D) + 1)
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s459786599
Wrong Answer
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
def li(): return list(map(int, input().split())) if __name__ == "__main__": n = int(input()) a_dict = {} for i in range(n): a_dict[i + 1] = li() date = 0 count = 0 index = 1 exists = set() while count < n * (n - 1) // 2: # print('index:', index) target1 = a_dict[index] # print('target1:', target1) if len(target1) == 0: index = index + 1 if index > n: # print('next date') index = 1 exists = set() else: value1 = target1.pop(0) # print('value1:', value1) target2 = a_dict[value1] # print('target2:', target2) if len(target2) == 0: # print('not found') date = -1 break else: value2 = target2.pop(0) # print('value2:', value2) if value1 not in exists and index not in exists: if value2 != index: # print('duplicate') date = -1 break elif len(exists) == 0: date = date + 1 exists.add(value1) exists.add(value2) # print('exists:', exists) count = count + 1 else: target1.insert(0, value1) target2.insert(0, value2) index = index + 1 if index > n: # print('next date') index = 1 exists = set() # print(a_dict) print(date) # 1日にできる試合は最大 n//2 # n(n-1)// 2 // (n//2) # n//2 = n/2 or n-1/2 # n or n-1 # できるかできないかは判定できるか? #
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s546366403
Wrong Answer
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
def getT(i, j): if i < j: return T[i - 1][j - i - 1] else: return getT(j, i) def setT(i, j, value): if i < j: T[i - 1][j - i - 1] = value else: return setT(j, i, value) def calc(N): A = [int(s) for s in input().split()] count = 1 for a in A: setT(1, a, count) count += 1 result = 0 for i in range(2, N): A = [int(s) for s in input().split()] count = 1 for a in A: b = getT(i, a) if b == 0: C = [getT(a, j) for j in range(1, i) if a != j] C.sort() for c in C: if count != c: break count += 1 setT(i, a, count) else: count = b + 1 result = max(result, count) A = [int(s) for s in input().split()] B = [getT(a, N) for a in A] for i in range(N - 2): if B[i] > B[i + 1]: return -1 return result N = int(input()) T = [[0 for _ in range(N - i - 1)] for i in range(N - 1)] print(calc(N))
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s106253696
Accepted
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
# cf. https://atcoder.jp/contests/abc139/submissions/7298439 from collections import deque N = int(input()) A = [deque(a - 1 for a in map(int, input().split())) for _ in range(N)] matchAvailablePlayers = deque( range(N) ) # 対戦可能な状態にある選手リスト 最初は全選手が対戦可能状態 daysPassedWhenPlayedMostRecentMatch = [0] * N desiredOpponentIdx = [-1] * N # i番目の選手が次に対戦を希望する相手の番号が[i]に入る while matchAvailablePlayers: playerIdx = matchAvailablePlayers.popleft() matchesOrderForThisPlayer = A[playerIdx] # 鏡像コピー! if not matchesOrderForThisPlayer: # この選手はもう全ての相手と対戦した continue opponentIdx = ( matchesOrderForThisPlayer.popleft() ) # 現時点で一番最後に対戦したい相手のindex if desiredOpponentIdx[opponentIdx] == playerIdx: # 対戦成立 daysPassedWhenPlayedMostRecentMatch[playerIdx] = ( daysPassedWhenPlayedMostRecentMatch[opponentIdx] ) = ( max( daysPassedWhenPlayedMostRecentMatch[playerIdx], daysPassedWhenPlayedMostRecentMatch[opponentIdx], ) + 1 ) # 互いの「試合に至った日」をどちらか遅い方に合わせその翌日である今日に書き換える matchAvailablePlayers.append(playerIdx) # 試合終了、対戦可能リストに加える matchAvailablePlayers.append(opponentIdx) else: # 相手が自分との対戦を望んでいないので対戦できない、このプレイヤーは対戦待ちをする desiredOpponentIdx[playerIdx] = opponentIdx if any( A ): # リストのリストなので、if A:だと空リストが中に存在しているだけでもTrueになってしまう print(-1) else: print(max(daysPassedWhenPlayedMostRecentMatch))
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s551849047
Wrong Answer
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
N = int(input()) X = N + 1 def to_node(i, j): if i < j: return i * X + j else: return j * X + i def parse_node(node): return (node // X, node % X) a_table = [] v_table = [] r_table = [] for i in range(N): for j in range(N): v_table.append(set()) r_table.append(set()) for i in range(N): row = [j - 1 for j in map(int, input().strip().split())] a_table.append(row) prev = to_node(i, row[0]) for j in range(1, N - 1): node = to_node(i, row[j]) v_table[prev].add(node) r_table[node].add(prev) prev = node def t_sort(): queue = set() for i in range(N): for j in range(i): node = to_node(i, j) if len(r_table[node]) == 0: queue.add(node) queue = [(node, 1) for node in queue] # print(queue) schedule = [set() for i in range(N * N)] while queue: node, day = queue.pop() i, j = parse_node(node) # print(i, j) while True: s = schedule[day] day += 1 if not (i in s or j in s): s.add(i) s.add(j) for next_node in v_table[node]: table = r_table[next_node] table.remove(node) if len(table) == 0: queue.append((next_node, day)) break for i in range(N): for j in range(i): node = to_node(i, j) if len(r_table[node]) != 0: return -1 for i in range(N * N - 1, 0, -1): if len(schedule[i]) != 0: return i return -1 # print(a_table) # for row in v_table: # print(list(map(lambda x: (x // X, x % X), row))) print(t_sort())
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s098759223
Runtime Error
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
n = int(input()) g = {(i, j): set() for i in range(n + 1) for j in range(n + 1) if i < j} visit = {(i, j): 0 for i in range(n + 1) for j in range(n + 1) if i < j} d = {(i, j): 0 for i in range(n + 1) for j in range(n + 1) if i < j} inf = 10**10 for i in range(1, n + 1): last = (0, 1) for j in list(map(int, input().split())): current = (min(i, j), max(i, j)) g[last].add(current) last = current def dfs(u): if visit[u] == 2: return d[u] if len(g[u]) == 0: return 0 ans = 0 visit[u] = 1 for v in g[u]: if visit[v] == 1: print(-1) exit(0) ans = max(ans, 1 + dfs(v)) visit[u] = 2 d[u] = ans return d[u] print(dfs((0, 1)))
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s932687915
Runtime Error
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
import sys # from collections import deque input = sys.stdin.readline def main(): n = int(input()) v = n * (n - 1) // 2 A = [list(map(int, input().split())) for _ in range(n)] # 頂点と i vs j との対応は (i < j) # (n-j+i)(n-j+i-1)//2 + i path = [set() for _ in range(v)] def vertex(vs1, vs2): m, M = sorted([vs1, vs2]) return (n - M + m) * (n - M + m - 1) // 2 + m parent = set(range(v)) for i in range(n): for j in range(1, n - 1): vs = vertex(i, A[i][j] - 1) vsp = vertex(i, A[i][j - 1] - 1) path[vs].add(vsp) if vsp in parent: parent.remove(vsp) def dfs(start): if memo[start] != -1: return memo[start] # que = deque([(start,1)]) # ret = 0 # while que: # p,d = que.pop() # for nxt in path[p]: # ret = max(ret,d+1) # que.append((nxt,d+1)) ret = 1 for nxt in path[start]: ret = max(ret, dfs(nxt) + 1) memo[start] = ret return ret ans = -1 memo = [-1] * v for i in parent: ans = max(ans, dfs(i)) print(ans) main()
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s879740015
Wrong Answer
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
from collections import deque n = int(input()) A = [] for i in range(n): A.append([int(i) for i in input().split()]) nn = n * (n - 1) // 2 F = [[0] * (n + 1) for _ in range(n + 1)] cur = 0 for i in range(1, n): for j in range(i + 1, n + 1): F[i][j] = cur F[j][i] = cur cur += 1 Edge = [[] for _ in range(nn)] Deg = [0] * nn for i in range(n): s = F[i + 1][A[i][0]] for j in range(1, n - 1): t = F[i + 1][A[i][j]] Edge[s].append(t) Deg[t] += 1 s = t ans = 1 S = [i for i in range(nn) if Deg[i] == 0] D = deque() DD = deque(S) while DD: D = DD DD = deque() while D: d = D.popleft() for g in Edge[d]: Deg[g] -= 1 if Deg[g] == 0: DD.append(g) S.append(g) ans += 1 print(-1 if ans == 0 else ans)
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`. * * *
s694929822
Wrong Answer
p02925
Input is given from Standard Input in the following format: N A_{1, 1} A_{1, 2} \ldots A_{1, N-1} A_{2, 1} A_{2, 2} \ldots A_{2, N-1} : A_{N, 1} A_{N, 2} \ldots A_{N, N-1}
N = int(input()) A = [[int(i) for i in input().split()] for j in range(N)] for i in range(N): A[i].append(-1) A[i] = [int(s) for s in A[i]] # Hはリスト def search(H): list = [] counter = 0 for i in range(N): if H.count(i + 1) > 0: l = H.index(i + 1) if H[i] == l + 1 and l > i: list.append((i, l)) counter += 1 list.append(counter) return list depth_col = [0] * N look = [] for _ in range(N): look.append(A[_][0]) counter = 0 while min(depth_col) < N - 1: result = search(look) if result[-1] == 0: break else: lengh_search = len(result) - 1 for j in range(lengh_search): x = result[j][0] y = result[j][1] depth_col[x] += 1 depth_col[y] += 1 a = depth_col[x] b = depth_col[y] look[x] = A[x][a] look[y] = A[y][b] counter += 1 print(counter)
Statement N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N. The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required. * Each player plays at most one matches in a day. * Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.
[{"input": "3\n 2 3\n 1 3\n 1 2", "output": "3\n \n\nAll the conditions can be satisfied if the matches are scheduled for three\ndays as follows:\n\n * Day 1: Player 1 vs Player 2\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 2 vs Player 3\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "4\n 2 3 4\n 1 3 4\n 4 1 2\n 3 1 2", "output": "4\n \n\nAll the conditions can be satisfied if the matches are scheduled for four days\nas follows:\n\n * Day 1: Player 1 vs Player 2, Player 3 vs Player 4\n * Day 2: Player 1 vs Player 3\n * Day 3: Player 1 vs Player 4, Player 2 vs Player 3\n * Day 4: Player 2 vs Player 4\n\nThis is the minimum number of days required.\n\n* * *"}, {"input": "3\n 2 3\n 3 1\n 1 2", "output": "-1\n \n\nAny scheduling of the matches violates some condition."}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s994693115
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
n = int(input()) a = list(map(int,input().split())) a_n4 = a_4 = [x for x in a if x%4!=0] a_4 = [x for x in a if x%4==0] a_2 = [x for x in a if x%4!=0 and x%2==0] if (len(a_n4)<=1+len(a_4) and len(a_2)<=1) or (len(a_n4)<=len(a_4) and len(a_2)>1) ): print("Yes") else: print("No")
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s631030174
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) a = list(map(int,input().split())) one = 0 four = 0 two = 0 for j in range(N): if a[j]%2 == 1: one += 1 elif a[j]%4 == 0: four += 1 else : two +=1 if one =< four: print('Yes') else : if (two == 0 and four == one -1): print('Yes') else: print('No')
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s322372863
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
fuga = input() hoge = list(map(int,input().split())) count_even = 0 count_divisibleBy4 = 0 for i in hoge: if i % 2 == 0: count_even += 1 if i % 4 == 0: count_divisibleBy4 += 1 if count_even == len(hoge) or count_divisibleBy4 >= len(hoge) // 2: print('Yes') else: print('No')
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s085024540
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) a = list(map(int,input().split())) one = 0 four = 0 two = 0 for j in range(N): if a[j]%2 == 1: one += 1 elif a[j]%4 == 0: four += 1 else : two +=1 if one =< four or (two == 0 and four == one-1): print('Yes') else: print('No')
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s899397586
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) a = list(map(int,input().split())) one = 0 four = 0 two = 0 for j in range(N): if a[j]%2 == 1: one += 1 elif a[j]%4 == 0: four += 1 else : two +=1 if one =< four: print('Yes') else : if two == 0 and four == one -1: print('Yes') else: print('No')
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s378563076
Accepted
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
# C - 4-adjacent n, a = int(input()), [int(x) % 4 for x in input().split()] print("Yes" if n // 2 <= a.count(0) + a.count(2) // 2 else "No")
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s880808894
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
n=int(input()) a=list(map(int, input().split())) b=len(a) c=len([i for i in a if i%2==0]) a2=len([i for i in a if i%4==0]) a1,a0=c-a2,b-c if a0>0 and a2>=a0-1 and a2+a1>=2: print('Yes') elif: a2+a1>=2: print('Yes') else: print('No')
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s178673444
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N=int(input()) a_list = list(map(int, input().split())) multi4 = lambda a: a % 4 == 0 multi4_count = sum(map(multi4, a_list)) multi2 = lambda a: a % 2 == 0 multi2_count = sum(map(multi2, a_list)) - multi4_count max_N = multi4_count*2 + (multi4_count>0)) + multi2_count//2 print("No" if (N > max_N) else "Yes")
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s009943343
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N=int(input()) a=list(map(int,input().split())) b4=[x for x in a if x%4==0] a4=[x for x in a if x%4!=0] b2=[x for x in a4 if x%2==0] c=[x for x in a4 if x%2!=0] if len(b4)==0 and (len(c)==0 and len(b2)>1): print('Yes') elif len(b4)==0 and len(c)!=0 print('No') elif len(b4)+1<len(c): print('No') elif len(b4)<len(c) and len(b2)>0: print('No') else: print('Yes')
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s769501095
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
n=int(input()) a=list(map(int,input().split())) a.sort() c4=0 c2=0 for i in range(n): if a[i]%4==0: c4+=1 for i in range(n): if a[i]%4!=0 and a[i]%2==0: c2+=1 if c4==0: if all(for a[i]%2==0 i in range(n)): print('Yes') elif n<=2*c4 + c2: print('Yes') else: print('No')
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s813405215
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) a = list(map(int,input().split())) one = 0 four = 0 two = 0 for j in range(N): if a[j]%2 == 1: one += 1 elif a[j]%4 == 0: four += 1 else : two +=1 if one =< four: print('Yes') else : if two == 0: if four == one-1: print('Yes') else: print("No") else: print('No')
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
If Snuke can achieve his objective, print `Yes`; otherwise, print `No`. * * *
s372447396
Runtime Error
p03637
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N
N = int(input()) a = list(map(int,input().rstrip().split(" "))) counter = [0,0,0] for i in a: if i % 4 == 0: counter[2] += 1 elif i % 2 == 0: counter[1] += 1 else: counter[0] += 1 counter[0] += min(1,counter[1] += 1) if counter[2] += 1 >= counter[0]: print("Yes") else: print("No")
Statement We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
[{"input": "3\n 1 10 100", "output": "Yes\n \n\nOne solution is (1, 100, 10).\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "No\n \n\nIt is impossible to permute a so that the condition is satisfied.\n\n* * *"}, {"input": "3\n 1 4 1", "output": "Yes\n \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "2\n 1 1", "output": "No\n \n\n* * *"}, {"input": "6\n 2 7 1 8 2 8", "output": "Yes"}]
Print the remainder in a line.
s544206768
Accepted
p02476
Two integers $A$ and $B$ separated by a space character are given in a line.
a = [int(i) for i in input().split()] print(a[0] % a[1])
Remainder of Big Integers Given two integers $A$ and $B$, compute the remainder of $\frac{A}{B}$.
[{"input": "5 8", "output": "5"}, {"input": "100 25", "output": "0"}]
Print the remainder in a line.
s265356777
Accepted
p02476
Two integers $A$ and $B$ separated by a space character are given in a line.
print(eval(input().replace(" ", "%")))
Remainder of Big Integers Given two integers $A$ and $B$, compute the remainder of $\frac{A}{B}$.
[{"input": "5 8", "output": "5"}, {"input": "100 25", "output": "0"}]
Print the remainder in a line.
s820661495
Accepted
p02476
Two integers $A$ and $B$ separated by a space character are given in a line.
a = input().split() print(int(a[0]) % int(a[1]))
Remainder of Big Integers Given two integers $A$ and $B$, compute the remainder of $\frac{A}{B}$.
[{"input": "5 8", "output": "5"}, {"input": "100 25", "output": "0"}]
Print the remainder in a line.
s698283461
Accepted
p02476
Two integers $A$ and $B$ separated by a space character are given in a line.
a, b = input().split() print(int(a) % int(b))
Remainder of Big Integers Given two integers $A$ and $B$, compute the remainder of $\frac{A}{B}$.
[{"input": "5 8", "output": "5"}, {"input": "100 25", "output": "0"}]
Print the maximum possible number of honest persons among the N people. * * *
s668270583
Runtime Error
p02837
Input is given from Standard Input in the following format: N A_1 x_{11} y_{11} x_{12} y_{12} : x_{1A_1} y_{1A_1} A_2 x_{21} y_{21} x_{22} y_{22} : x_{2A_2} y_{2A_2} : A_N x_{N1} y_{N1} x_{N2} y_{N2} : x_{NA_N} y_{NA_N}
def max_honest(n_ppl, testimonies): formating_str = "{0:0" + str(n_ppl) + "b}" max = 0 for i in range(1, 2**n_ppl + 1): current_val = formating_str.format(2**n_ppl - i) potential = True valid_testemonies = [] for j in range(0, len(current_val)): if current_val[j] == "1": for k in range(0, len(testimonies[j])): valid_testemonies.append(testimonies[j][k]) for j in range(0, len(valid_testemonies)): if str(valid_testemonies[j][1]) != current_val[valid_testemonies[j][0] - 1]: potential = False break if potential: if current_val.count("1") > max: max = current_val.count("1") return max testimonies = [] n_ppl = int(input()) for i in range(0, n_ppl): tests = [] n_tests = int(input()) for j in range(0, n_tests): test = input().split(" ") test = (int(test[0]), int(test[1])) tests.append(test) testimonies.append(tests) print("") print(max_honest(n_ppl, testimonies)) input("Press enter")
Statement There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind. How many honest persons can be among those N people at most?
[{"input": "3\n 1\n 2 1\n 1\n 1 1\n 1\n 2 0", "output": "2\n \n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest\npersons without inconsistencies, which is the maximum possible number of\nhonest persons.\n\n* * *"}, {"input": "3\n 2\n 2 1\n 3 0\n 2\n 3 1\n 1 0\n 2\n 1 1\n 2 0", "output": "0\n \n\nAssuming that one or more of them are honest immediately leads to a\ncontradiction.\n\n* * *"}, {"input": "2\n 1\n 2 0\n 1\n 1 0", "output": "1"}]
Print the maximum possible number of honest persons among the N people. * * *
s001927645
Wrong Answer
p02837
Input is given from Standard Input in the following format: N A_1 x_{11} y_{11} x_{12} y_{12} : x_{1A_1} y_{1A_1} A_2 x_{21} y_{21} x_{22} y_{22} : x_{2A_2} y_{2A_2} : A_N x_{N1} y_{N1} x_{N2} y_{N2} : x_{NA_N} y_{NA_N}
print(15)
Statement There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind. How many honest persons can be among those N people at most?
[{"input": "3\n 1\n 2 1\n 1\n 1 1\n 1\n 2 0", "output": "2\n \n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest\npersons without inconsistencies, which is the maximum possible number of\nhonest persons.\n\n* * *"}, {"input": "3\n 2\n 2 1\n 3 0\n 2\n 3 1\n 1 0\n 2\n 1 1\n 2 0", "output": "0\n \n\nAssuming that one or more of them are honest immediately leads to a\ncontradiction.\n\n* * *"}, {"input": "2\n 1\n 2 0\n 1\n 1 0", "output": "1"}]
Print the maximum possible number of honest persons among the N people. * * *
s479218579
Runtime Error
p02837
Input is given from Standard Input in the following format: N A_1 x_{11} y_{11} x_{12} y_{12} : x_{1A_1} y_{1A_1} A_2 x_{21} y_{21} x_{22} y_{22} : x_{2A_2} y_{2A_2} : A_N x_{N1} y_{N1} x_{N2} y_{N2} : x_{NA_N} y_{NA_N}
def hou2(tarrs, s, N): def checkTestimony(s, t): scopy = s[:] for i in range(len(s)): if s[i] != t[i] and s[i] != 0 and t[i] != 0: return None if t[i]: scopy[i] = t[i] return scopy def search(pos, N, s, acc): if pos < N: check_tp = checkTestimony(s, tarrs[pos]) if s[pos] == 1: s[pos] = -1 if check_tp: check_tp[pos] = 1 return search(pos + 1, N, check_tp, acc + 1) else: return 0 if check_tp and s[pos] == 0: s[pos] = -1 check_tp[pos] = 1 return max( search(pos + 1, N, check_tp, acc + 1), search(pos + 1, N, s, acc) ) else: # testimony unacceptable, assuming unkind s[pos] = -1 return search(pos + 1, N, s, acc) else: return acc return search(0, N, s, 0) if __name__ == "__main__": import sys in_arr = [] for line in sys.stdin: in_arr.append([int(_) for _ in line.strip().split()]) N = in_arr[0][0] i = 1 tarrs = [] s = [0] * N while i < len(in_arr): tnum = in_arr[i][0] tarr = [0] * N for j in range(tnum): x, y = in_arr[1 + j + i] tarr[x - 1] = 1 if y else -1 # -1 claimed unkind, 1 claimed honest if tarr[len(tarrs)] == -1: # claimed self to be unkind s[len(tarrs)] = -1 tarrs.append(tarr) i += tnum + 1 print(hou2(tarrs, s, N))
Statement There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind. How many honest persons can be among those N people at most?
[{"input": "3\n 1\n 2 1\n 1\n 1 1\n 1\n 2 0", "output": "2\n \n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest\npersons without inconsistencies, which is the maximum possible number of\nhonest persons.\n\n* * *"}, {"input": "3\n 2\n 2 1\n 3 0\n 2\n 3 1\n 1 0\n 2\n 1 1\n 2 0", "output": "0\n \n\nAssuming that one or more of them are honest immediately leads to a\ncontradiction.\n\n* * *"}, {"input": "2\n 1\n 2 0\n 1\n 1 0", "output": "1"}]
Print the maximum possible number of honest persons among the N people. * * *
s078289075
Runtime Error
p02837
Input is given from Standard Input in the following format: N A_1 x_{11} y_{11} x_{12} y_{12} : x_{1A_1} y_{1A_1} A_2 x_{21} y_{21} x_{22} y_{22} : x_{2A_2} y_{2A_2} : A_N x_{N1} y_{N1} x_{N2} y_{N2} : x_{NA_N} y_{NA_N}
import itertools as it def all_same(items): return all(x == items[0] for x in items) Num = input() persons = [] for i in range(0, Num): stuff = [] for i in range(0, input()): stuff.append(map(int, input().split(" "))) persons.append(stuff) n = 0 n2 = 0 for i in range(0, Num + 1): ultimatetruthtable = [None] * (Num) for j in list(it.combinations(range(Num), i)): for k in range(0, len(j)): for p in j[k]: for q in range(0, len(persons[p])): ultimatetruthtable[persons[p][q][0]].append(persons[p][q][1]) for r in ultimatetruthtable: if all_same(r): n = n + 1 if n == Num: n2 = i print(n2)
Statement There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind. How many honest persons can be among those N people at most?
[{"input": "3\n 1\n 2 1\n 1\n 1 1\n 1\n 2 0", "output": "2\n \n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest\npersons without inconsistencies, which is the maximum possible number of\nhonest persons.\n\n* * *"}, {"input": "3\n 2\n 2 1\n 3 0\n 2\n 3 1\n 1 0\n 2\n 1 1\n 2 0", "output": "0\n \n\nAssuming that one or more of them are honest immediately leads to a\ncontradiction.\n\n* * *"}, {"input": "2\n 1\n 2 0\n 1\n 1 0", "output": "1"}]
Print the maximum possible number of honest persons among the N people. * * *
s635078174
Wrong Answer
p02837
Input is given from Standard Input in the following format: N A_1 x_{11} y_{11} x_{12} y_{12} : x_{1A_1} y_{1A_1} A_2 x_{21} y_{21} x_{22} y_{22} : x_{2A_2} y_{2A_2} : A_N x_{N1} y_{N1} x_{N2} y_{N2} : x_{NA_N} y_{NA_N}
N = int(input()) lst = [[None for _ in range(N)] for _ in range(N)] for idx in range(N): num = int(input()) for idy in range(num): x, y = map(int, input().split()) lst[idx][x - 1] = y lst2 = [None for _ in range(N)] for idx in range(N): honestFlg = 1 for idy in range(N): if lst[idx][idy] == 1 and lst[idy][idx] == 0: honestFlg = 0 if lst2[idx] != 0: lst2[idx] = honestFlg if lst2[idx] == 1: for idy in range(N): if lst[idx][idy] == 0: lst2[idy] = 0 else: for idy in range(N): if lst[idy][idx] == 1: lst2[idy] = 0 print(sum(lst2))
Statement There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind. How many honest persons can be among those N people at most?
[{"input": "3\n 1\n 2 1\n 1\n 1 1\n 1\n 2 0", "output": "2\n \n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest\npersons without inconsistencies, which is the maximum possible number of\nhonest persons.\n\n* * *"}, {"input": "3\n 2\n 2 1\n 3 0\n 2\n 3 1\n 1 0\n 2\n 1 1\n 2 0", "output": "0\n \n\nAssuming that one or more of them are honest immediately leads to a\ncontradiction.\n\n* * *"}, {"input": "2\n 1\n 2 0\n 1\n 1 0", "output": "1"}]
Print the maximum possible number of honest persons among the N people. * * *
s674206265
Wrong Answer
p02837
Input is given from Standard Input in the following format: N A_1 x_{11} y_{11} x_{12} y_{12} : x_{1A_1} y_{1A_1} A_2 x_{21} y_{21} x_{22} y_{22} : x_{2A_2} y_{2A_2} : A_N x_{N1} y_{N1} x_{N2} y_{N2} : x_{NA_N} y_{NA_N}
n = int(input()) a = [] syogens = [] for i in range(n): a.append(int(input())) # 証言の個数 syogen = [None] * (n) for j in range(a[-1]): xij, yij = map(int, input().split(" ")) syogen[xij - 1] = yij syogens.append(syogen) # それぞれの人からみた正直者の数 person_cnt = [None] * n for i in range(n): # cnt = 0 # 順に証言を見ていく # 自分を正直と仮定 cnt += 1 for j, syogen in enumerate(syogens[i]): # 正直という評価があれば if syogen == 1: # 自分が正直なとき、正直と評価した対象の人が自分を正直と評価していたら矛盾しない if syogens[j][i] == 1: cnt += 1 # 自分が正直なとき、正直と評価した対象の人が自分を不親切と評価していたら矛盾する elif syogens[j][i] == 0: cnt -= 1 # 自分が不親切と評価した相手が自分を不親切と評価していても矛盾しない if syogen == 0: if syogens[j][i] == 0: pass # cnt += 1 person_cnt[i] = cnt print(max(person_cnt))
Statement There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind. How many honest persons can be among those N people at most?
[{"input": "3\n 1\n 2 1\n 1\n 1 1\n 1\n 2 0", "output": "2\n \n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest\npersons without inconsistencies, which is the maximum possible number of\nhonest persons.\n\n* * *"}, {"input": "3\n 2\n 2 1\n 3 0\n 2\n 3 1\n 1 0\n 2\n 1 1\n 2 0", "output": "0\n \n\nAssuming that one or more of them are honest immediately leads to a\ncontradiction.\n\n* * *"}, {"input": "2\n 1\n 2 0\n 1\n 1 0", "output": "1"}]
Print the maximum possible number of honest persons among the N people. * * *
s535994644
Wrong Answer
p02837
Input is given from Standard Input in the following format: N A_1 x_{11} y_{11} x_{12} y_{12} : x_{1A_1} y_{1A_1} A_2 x_{21} y_{21} x_{22} y_{22} : x_{2A_2} y_{2A_2} : A_N x_{N1} y_{N1} x_{N2} y_{N2} : x_{NA_N} y_{NA_N}
N = int(input()) tf_dict = {} for i, n in enumerate(range(N)): A = int(input()) tmp_dict = {} for a in range(A): xy = input().split() tmp_dict[int(xy[0])] = int(xy[1]) tf_dict[i + 1] = tmp_dict True_set = set() False_set = set() for key in tf_dict.keys(): for item in tf_dict[key].items(): if item[1] == 1: if (item[0] not in True_set) & (item[0] not in False_set): True_set.add(item[0]) True_set.add(key) elif item[0] in True_set: True_set.add(key) elif item[0] in False_set: False_set.add(key) if item[1] == 0: if (item[0] not in True_set) & (item[0] not in False_set): False_set.add(item[0]) True_set.add(key) elif item[0] in True_set: False_set.add(key) elif item[0] in False_set: True_set.add(key) if len(False_set & True_set) != 0: print("0") else: print(len(True_set))
Statement There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind. How many honest persons can be among those N people at most?
[{"input": "3\n 1\n 2 1\n 1\n 1 1\n 1\n 2 0", "output": "2\n \n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest\npersons without inconsistencies, which is the maximum possible number of\nhonest persons.\n\n* * *"}, {"input": "3\n 2\n 2 1\n 3 0\n 2\n 3 1\n 1 0\n 2\n 1 1\n 2 0", "output": "0\n \n\nAssuming that one or more of them are honest immediately leads to a\ncontradiction.\n\n* * *"}, {"input": "2\n 1\n 2 0\n 1\n 1 0", "output": "1"}]
Print the maximum possible number of honest persons among the N people. * * *
s676945445
Runtime Error
p02837
Input is given from Standard Input in the following format: N A_1 x_{11} y_{11} x_{12} y_{12} : x_{1A_1} y_{1A_1} A_2 x_{21} y_{21} x_{22} y_{22} : x_{2A_2} y_{2A_2} : A_N x_{N1} y_{N1} x_{N2} y_{N2} : x_{NA_N} y_{NA_N}
N = int(input()) # A = [] lst = [list(f"{i:0{N}b}") for i in range(2**N)] # X = [[] for i in range(N)] # Y = [[] for i in range(N)] # for i in range(N): # tmp_A = int(input()) # A.append(tmp_A) # for j in range(tmp_A): # tmp_x,tmp_y = input().split() # X[i].append(int(tmp_x)-1) # Y[i].append(tmp_y) ans = -1 # for i in range(2**N): # flag = 1 # for j in range(N): # if lst[i][j] == "1": # for k in range(A[j]): # if lst[i][X[j][k]] != Y[j][k]: # flag = 0 # if flag: # tmp = 0 # for j in lst[i]: # if j == "1": # tmp += 1 # if tmp > ans: # ans = tmp print(ans)
Statement There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind. How many honest persons can be among those N people at most?
[{"input": "3\n 1\n 2 1\n 1\n 1 1\n 1\n 2 0", "output": "2\n \n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest\npersons without inconsistencies, which is the maximum possible number of\nhonest persons.\n\n* * *"}, {"input": "3\n 2\n 2 1\n 3 0\n 2\n 3 1\n 1 0\n 2\n 1 1\n 2 0", "output": "0\n \n\nAssuming that one or more of them are honest immediately leads to a\ncontradiction.\n\n* * *"}, {"input": "2\n 1\n 2 0\n 1\n 1 0", "output": "1"}]
Print the maximum possible number of honest persons among the N people. * * *
s288447909
Wrong Answer
p02837
Input is given from Standard Input in the following format: N A_1 x_{11} y_{11} x_{12} y_{12} : x_{1A_1} y_{1A_1} A_2 x_{21} y_{21} x_{22} y_{22} : x_{2A_2} y_{2A_2} : A_N x_{N1} y_{N1} x_{N2} y_{N2} : x_{NA_N} y_{NA_N}
num_person = int(input()) tests_list = [] test_score_dict = {} for p in range(num_person): num_tests = int(input()) tests = [list(map(int, input().split())) for t in range(num_tests)] tests_list.append(tests) test_score_dict[p + 1] = 1 for unkinds in range(num_person + 1): honests = num_person - unkinds for i in range(num_person): num_target_person = len(tests_list[i]) for n in range(num_target_person): target_person = tests_list[i][n][0] target_person_test = tests_list[i][n][1] test_score_dict[target_person] *= target_person_test contra = honests - sum(test_score_dict.values()) if honests + contra <= num_person: print(honests) exit() print(0)
Statement There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not. Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind. How many honest persons can be among those N people at most?
[{"input": "3\n 1\n 2 1\n 1\n 1 1\n 1\n 2 0", "output": "2\n \n\nIf Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest\npersons without inconsistencies, which is the maximum possible number of\nhonest persons.\n\n* * *"}, {"input": "3\n 2\n 2 1\n 3 0\n 2\n 3 1\n 1 0\n 2\n 1 1\n 2 0", "output": "0\n \n\nAssuming that one or more of them are honest immediately leads to a\ncontradiction.\n\n* * *"}, {"input": "2\n 1\n 2 0\n 1\n 1 0", "output": "1"}]
Print the minimum necessary number of casts. * * *
s838612772
Wrong Answer
p03725
Input is given from Standard Input in the following format: H W K A_{1,1}A_{1,2}...A_{1,W} : A_{H,1}A_{H,2}...A_{H,W}
import sys from collections import deque input = sys.stdin.readline inf = 10**8 inf = 10 DX = (-1, 0, 1, 0, -1, -1, 1, 1) DY = (0, 1, 0, -1, -1, 1, -1, 1) DX = DX[:4] DY = DY[:4] H, W, K = map(int, input().split()) grid = [input().rstrip() for _ in range(H)] dist = [[inf] * W for _ in range(H)] node = [] for i in range(H): for j in range(W): if grid[i][j] == "S": node.append((i, j)) dist[i][j] = 1 # まず一回普通にBFS d = 0 memo = [] while d < K: nxt = [] while node: x, y = node.pop() if x in (0, H - 1) or y in (0, W - 1): print(dist[x][y]) exit() memo.append((x, y)) for dx, dy in zip(DX, DY): nx = x + dx ny = y + dy if nx < 0 or nx >= H or ny < 0 or ny >= W: continue if grid[nx][ny] == "#": continue if dist[nx][ny] >= inf: dist[nx][ny] = 1 nxt.append((nx, ny)) d += 1 node = nxt memo.extend(node) ans = inf for x, y in memo: tmp = min(x // K, (H - y) // K, y // K, (W - y) // K) + 1 ans = min(ans, tmp) print(ans)
Statement Takahashi is locked within a building. This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered. Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1). Takahashi will use his magic to get out of the building. In one cast, he can do the following: * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered. * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on. His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so. It is guaranteed that Takahashi is initially at a room without an exit.
[{"input": "3 3 3\n #.#\n #S.\n ###", "output": "1\n \n\nTakahashi can move to room (1,2) in one cast.\n\n* * *"}, {"input": "3 3 3\n ###\n #S#\n ###", "output": "2\n \n\nTakahashi cannot move in the first cast, but can unlock room (1,2). Then, he\ncan move to room (1,2) in the next cast, achieving the objective in two casts.\n\n* * *"}, {"input": "7 7 2\n #######\n #######\n ##...##\n ###S###\n ##.#.##\n ###.###\n #######", "output": "2"}]
Print the minimum necessary number of casts. * * *
s671664240
Runtime Error
p03725
Input is given from Standard Input in the following format: H W K A_{1,1}A_{1,2}...A_{1,W} : A_{H,1}A_{H,2}...A_{H,W}
from collections import deque;h,w,k=map(int,input().split());m=[input()for _ in[0]*h];v=[[-1]*w for _ in[0]*h];r=9**20 for i in range(h): if'S'in m[i]:j=m[i].index('S');q=deque([[i,j]])v[i][j]=0 while q: y,x=q.popleft() r=min(r,y,x,h-1-y,w-1-x) if v[y][x]==k:continue for i,j in([1,0],[-1,0],[0,1],[0,-1]): t,u=y+i,x+j if t>=0and t<h and u>=0and u<w and m[t][u]=='.'and v[t][u]<0:v[t][u]=v[y][x]+1;q.append([t,u]) print(1-(-r//k))
Statement Takahashi is locked within a building. This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered. Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1). Takahashi will use his magic to get out of the building. In one cast, he can do the following: * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered. * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on. His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so. It is guaranteed that Takahashi is initially at a room without an exit.
[{"input": "3 3 3\n #.#\n #S.\n ###", "output": "1\n \n\nTakahashi can move to room (1,2) in one cast.\n\n* * *"}, {"input": "3 3 3\n ###\n #S#\n ###", "output": "2\n \n\nTakahashi cannot move in the first cast, but can unlock room (1,2). Then, he\ncan move to room (1,2) in the next cast, achieving the objective in two casts.\n\n* * *"}, {"input": "7 7 2\n #######\n #######\n ##...##\n ###S###\n ##.#.##\n ###.###\n #######", "output": "2"}]
Print the minimum necessary number of casts. * * *
s244122624
Runtime Error
p03725
Input is given from Standard Input in the following format: H W K A_{1,1}A_{1,2}...A_{1,W} : A_{H,1}A_{H,2}...A_{H,W}
#include <bits/stdc++.h> //#include <math.h> using namespace std; #define INF 1.1e9 #define LINF 1.1e18 #define FOR(i,a,b) for (int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() #define pb push_back #define pf push_front #define fi first #define se second #define BIT(x,n) bitset<n>(x) #define PI 3.14159265358979323846 typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> PP; struct edge { int to, cost; edge(int t,int c):to(t),cost(c) {} }; int dx[]={1,-1,0,0},dy[]={0,0,1,-1}; //----------------------------------------------------------------------------- int H,W,K; string A[800]; int sx,sy; bool used[800][800]; bool ok(int x,int y) { return (x>=0&&x<W&&y>=0&&y<H&&A[y][x]!='#'&&!used[y][x]); } int calc(int y,int x) { return min(min(x,y),min(W-x-1,H-y-1)); } int main() { cin.tie(0); ios::sync_with_stdio(false); cin>>H>>W>>K; REP(i,H) { cin>>A[i]; REP(j,W) if(A[i][j]=='S') sx=j,sy=i; } queue<P> Q; Q.push(P(sx,sy)); used[sy][sx]=true; REP(i,K+1) { int sz=Q.size(); REP(j,sz) { P p=Q.front();Q.pop(); REP(d,4) { int nx=p.fi+dx[d],ny=p.se+dy[d]; if(ok(nx,ny)) { used[ny][nx]=true; Q.push(P(nx,ny)); } } } } int ans=INF; REP(i,H) { REP(j,W) { if(used[i][j]) ans=min(ans,calc(i,j)); } } cout<<(ans/K)+!!(ans%K)+1<<endl; return 0; }
Statement Takahashi is locked within a building. This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered. Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1). Takahashi will use his magic to get out of the building. In one cast, he can do the following: * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered. * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on. His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so. It is guaranteed that Takahashi is initially at a room without an exit.
[{"input": "3 3 3\n #.#\n #S.\n ###", "output": "1\n \n\nTakahashi can move to room (1,2) in one cast.\n\n* * *"}, {"input": "3 3 3\n ###\n #S#\n ###", "output": "2\n \n\nTakahashi cannot move in the first cast, but can unlock room (1,2). Then, he\ncan move to room (1,2) in the next cast, achieving the objective in two casts.\n\n* * *"}, {"input": "7 7 2\n #######\n #######\n ##...##\n ###S###\n ##.#.##\n ###.###\n #######", "output": "2"}]
Print the minimum necessary number of casts. * * *
s278731608
Accepted
p03725
Input is given from Standard Input in the following format: H W K A_{1,1}A_{1,2}...A_{1,W} : A_{H,1}A_{H,2}...A_{H,W}
import math # import numpy as np import queue from collections import deque, defaultdict import heapq as hpq from sys import stdin, setrecursionlimit # from scipy.sparse.csgraph import dijkstra # from scipy.sparse import csr_matrix ipt = stdin.readline setrecursionlimit(10**7) def main(): h, w, k = map(int, ipt().split()) a = [input() for _ in range(h)] for i, ai in enumerate(a): if "S" in ai: si = i sj = ai.find("S") break q = queue.Queue() t = [[10**10] * w for _ in [0] * h] dir = [(-1, 0), (1, 0), (0, -1), (0, 1)] t[si][sj] = 0 q.put((si, sj)) g1 = [(si, sj)] while not q.empty(): qi, qj = q.get() for di, dj in dir: if ( 0 <= qi + di <= h - 1 and 0 <= qj + dj <= w - 1 and a[qi + di][qj + dj] == "." ): if t[qi + di][qj + dj] > t[qi][qj] + 1: t[qi + di][qj + dj] = t[qi][qj] + 1 g1.append((qi + di, qj + dj)) if t[qi][qj] != k - 1: q.put((qi + di, qj + dj)) mi = 10**4 for i, j in g1: if mi > (i + k - 1) // k + 1: mi = (i + k - 1) // k + 1 if mi > (j + k - 1) // k + 1: mi = (j + k - 1) // k + 1 if mi > (h - 1 - i + k - 1) // k + 1: mi = (h - 1 - i + k - 1) // k + 1 if mi > (w - 1 - j + k - 1) // k + 1: mi = (w - 1 - j + k - 1) // k + 1 print(mi) return if __name__ == "__main__": main()
Statement Takahashi is locked within a building. This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered. Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1). Takahashi will use his magic to get out of the building. In one cast, he can do the following: * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered. * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on. His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so. It is guaranteed that Takahashi is initially at a room without an exit.
[{"input": "3 3 3\n #.#\n #S.\n ###", "output": "1\n \n\nTakahashi can move to room (1,2) in one cast.\n\n* * *"}, {"input": "3 3 3\n ###\n #S#\n ###", "output": "2\n \n\nTakahashi cannot move in the first cast, but can unlock room (1,2). Then, he\ncan move to room (1,2) in the next cast, achieving the objective in two casts.\n\n* * *"}, {"input": "7 7 2\n #######\n #######\n ##...##\n ###S###\n ##.#.##\n ###.###\n #######", "output": "2"}]
Print the minimum necessary number of casts. * * *
s264517024
Accepted
p03725
Input is given from Standard Input in the following format: H W K A_{1,1}A_{1,2}...A_{1,W} : A_{H,1}A_{H,2}...A_{H,W}
def main(): h, w, k = map(int, input().split()) grid = ["." * (w + 2)] + ["." + input() + "." for _ in [0] * h] + ["." * (w + 2)] visit = [[False] * (w + 2) for _ in [0] * (h + 2)] for i in range(h + 2): for j in range(w + 2): if grid[i][j] == "S": start = (i, j) break visit[start[0]][start[1]] = True q = [start] for i in range(k): q2 = [] while q: x, y = q.pop() if x - 1 >= 0: if grid[x - 1][y] == "." and visit[x - 1][y] is False: q2.append((x - 1, y)) visit[x - 1][y] = True if x + 1 <= h + 1: if grid[x + 1][y] == "." and visit[x + 1][y] is False: q2.append((x + 1, y)) visit[x + 1][y] = True if y - 1 >= 0: if grid[x][y - 1] == "." and visit[x][y - 1] is False: q2.append((x, y - 1)) visit[x][y - 1] = True if y + 1 <= w + 1: if grid[x][y + 1] == "." and visit[x][y + 1] is False: q2.append((x, y + 1)) visit[x][y + 1] = True q = q2 dist = 10**9 for i in range(h + 2): for j in range(w + 2): if visit[i][j]: dist = min([dist, i, h + 1 - i, j, w + 1 - j]) print((max(dist - 1, 0) - 1) // k + 2) main()
Statement Takahashi is locked within a building. This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered. Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1). Takahashi will use his magic to get out of the building. In one cast, he can do the following: * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered. * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on. His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so. It is guaranteed that Takahashi is initially at a room without an exit.
[{"input": "3 3 3\n #.#\n #S.\n ###", "output": "1\n \n\nTakahashi can move to room (1,2) in one cast.\n\n* * *"}, {"input": "3 3 3\n ###\n #S#\n ###", "output": "2\n \n\nTakahashi cannot move in the first cast, but can unlock room (1,2). Then, he\ncan move to room (1,2) in the next cast, achieving the objective in two casts.\n\n* * *"}, {"input": "7 7 2\n #######\n #######\n ##...##\n ###S###\n ##.#.##\n ###.###\n #######", "output": "2"}]
Print the minimum necessary number of casts. * * *
s123405273
Wrong Answer
p03725
Input is given from Standard Input in the following format: H W K A_{1,1}A_{1,2}...A_{1,W} : A_{H,1}A_{H,2}...A_{H,W}
# coding: utf-8 # Your code here! import heapq as hq H, W, K = map(int, input().split()) A = [] X, Y = 0, 1 start = None for h in range(H): tmp = list(input()) A.append(tmp) if "S" in tmp: start = (tmp.index("S"), h) def minCost(x, y): return min(start[X], W - 1 - start[X], start[Y], H - 1 - start[Y]) // K search = [] searched = [[False for w in range(W)] for h in range(H)] hq.heapify(search) hq.heappush(search, (minCost(start[X], start[Y]), 0, 0, 0, start)) vector = [(1, 0), (-1, 0), (0, 1), (0, -1)] while len(search) > 0: _, cost, wall, walk, pos = hq.heappop(search) x, y = pos[X], pos[Y] if searched[y][x]: continue if x == 0 or x == W - 1 or y == 0 or y == H - 1: print(cost) break searched[y][x] = True for v in vector: new_x, new_y = x + v[X], y + v[Y] if not searched[new_y][new_x]: new_cost, new_wall, new_walk = cost, wall, walk if A[new_y][new_x] == "#": new_wall += 1 if new_wall > 0: new_cost += 1 new_wall = -K + 1 new_walk += 1 if new_walk > 0: new_cost += 1 new_walk = -K + 1 hq.heappush( search, ( new_cost + minCost(new_x, new_y), new_cost, new_wall, new_walk, (new_x, new_y), ), )
Statement Takahashi is locked within a building. This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered. Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1). Takahashi will use his magic to get out of the building. In one cast, he can do the following: * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered. * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on. His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so. It is guaranteed that Takahashi is initially at a room without an exit.
[{"input": "3 3 3\n #.#\n #S.\n ###", "output": "1\n \n\nTakahashi can move to room (1,2) in one cast.\n\n* * *"}, {"input": "3 3 3\n ###\n #S#\n ###", "output": "2\n \n\nTakahashi cannot move in the first cast, but can unlock room (1,2). Then, he\ncan move to room (1,2) in the next cast, achieving the objective in two casts.\n\n* * *"}, {"input": "7 7 2\n #######\n #######\n ##...##\n ###S###\n ##.#.##\n ###.###\n #######", "output": "2"}]
Print the minimum necessary number of casts. * * *
s273674909
Accepted
p03725
Input is given from Standard Input in the following format: H W K A_{1,1}A_{1,2}...A_{1,W} : A_{H,1}A_{H,2}...A_{H,W}
import collections def solve(): def calc(x, y): cnt1 = (x + k - 1) // k cnt2 = (w - 1 - x + k - 1) // k cnt3 = (y + k - 1) // k cnt4 = (h - 1 - y + k - 1) // k return min(cnt1, cnt2, cnt3, cnt4) h, w, k = map(int, input().split()) boards = [tuple(input()) for _ in range(h)] for i in range(h): for j in range(w): if boards[i][j] == "S": sx = j sy = i break q = collections.deque() checked = [[0] * w for _ in range(h)] checked[sy][sx] = 1 q.append((sx, sy, 0)) ans = 1 + calc(sx, sy) while 1: if len(q) == 0: break tx, ty, cnt = q.popleft() if cnt == k + 1: break ans = min(ans, 1 + calc(tx, ty)) if tx != 0 and boards[ty][tx - 1] != "#" and checked[ty][tx - 1] == 0: checked[ty][tx - 1] = 1 q.append((tx - 1, ty, cnt + 1)) if tx != w - 1 and boards[ty][tx + 1] != "#" and checked[ty][tx + 1] == 0: checked[ty][tx + 1] = 1 q.append((tx + 1, ty, cnt + 1)) if ty != 0 and boards[ty - 1][tx] != "#" and checked[ty - 1][tx] == 0: checked[ty - 1][tx] = 1 q.append((tx, ty - 1, cnt + 1)) if ty != h - 1 and boards[ty + 1][tx] != "#" and checked[ty + 1][tx] == 0: checked[ty + 1][tx] = 1 q.append((tx, ty + 1, cnt + 1)) print(ans) solve()
Statement Takahashi is locked within a building. This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered. Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1). Takahashi will use his magic to get out of the building. In one cast, he can do the following: * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered. * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on. His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so. It is guaranteed that Takahashi is initially at a room without an exit.
[{"input": "3 3 3\n #.#\n #S.\n ###", "output": "1\n \n\nTakahashi can move to room (1,2) in one cast.\n\n* * *"}, {"input": "3 3 3\n ###\n #S#\n ###", "output": "2\n \n\nTakahashi cannot move in the first cast, but can unlock room (1,2). Then, he\ncan move to room (1,2) in the next cast, achieving the objective in two casts.\n\n* * *"}, {"input": "7 7 2\n #######\n #######\n ##...##\n ###S###\n ##.#.##\n ###.###\n #######", "output": "2"}]
Print the number of the sets of bowls of ramen that satisfy the conditions, disregarding order, modulo M. * * *
s355319444
Accepted
p03375
Input is given from Standard Input in the following format: N M
# coding: utf-8 # Your code here! import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline # 文字列入力のときは注意 n, MOD = [int(i) for i in readline().split()] SIZE = 3001 # MOD=10**9+7 #998244353 #ここを変更する SIZE += 1 inv = [0] * SIZE # inv[j] = j^{-1} mod MOD fac = [0] * SIZE # fac[j] = j! mod MOD finv = [0] * SIZE # finv[j] = (j!)^{-1} mod MOD inv[1] = 1 fac[0] = fac[1] = 1 finv[0] = finv[1] = 1 for i in range(2, SIZE): inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD fac[i] = fac[i - 1] * i % MOD finv[i] = finv[i - 1] * inv[i] % MOD def choose(n, r): # nCk mod MOD の計算 if 0 <= r <= n: return (fac[n] * finv[r] % MOD) * finv[n - r] % MOD else: return 0 """ make the table of Sterling numbers of the second kind Sterling[ball][box] SIZE = n Sterling2 = [[0]*(SIZE+1) for _ in range(SIZE+1)] Sterling2[0][0] = Sterling2[1][1] = 1 for i in range(2,SIZE+1): for k in range(1,i+1): Sterling2[i][k] = (Sterling2[i-1][k-1] + k*Sterling2[i-1][k])%MOD """ SIZE = n + 1 f = [[0] * (SIZE) for _ in range(SIZE)] f[0][0] = 1 for i in range(1, SIZE): f[i][0] = 1 for k in range(1, i + 1): f[i][k] = (f[i - 1][k] + f[i - 1][k - 1] + k * f[i - 1][k]) % MOD # print(f) # pow(2,n-s,MOD-1) pp = [1] * SIZE for i in range(1, SIZE): pp[i] = 2 * pp[i - 1] % (MOD - 1) def size(s): """ for b in range(n+1): res += f[s][b]*pow(2,b*(n-s),MOD) """ res = 0 p = 1 e = pow(2, (n - s), MOD) for b in range(SIZE): res += f[s][b] * p p *= e p %= MOD return res * pow(2, pp[n - s], MOD) % MOD # for i in range(n+1): # print(size(i)) ans = 0 sgn = 1 for j in range(n + 1): ans += sgn * choose(n, j) * size(j) ans %= MOD sgn *= -1 print(ans)
Statement In "Takahashi-ya", a ramen restaurant, basically they have one menu: "ramen", but N kinds of toppings are also offered. When a customer orders a bowl of ramen, for each kind of topping, he/she can choose whether to put it on top of his/her ramen or not. There is no limit on the number of toppings, and it is allowed to have all kinds of toppings or no topping at all. That is, considering the combination of the toppings, 2^N types of ramen can be ordered. Akaki entered Takahashi-ya. She is thinking of ordering some bowls of ramen that satisfy both of the following two conditions: * Do not order multiple bowls of ramen with the exactly same set of toppings. * Each of the N kinds of toppings is on two or more bowls of ramen ordered. You are given N and a prime number M. Find the number of the sets of bowls of ramen that satisfy these conditions, disregarding order, modulo M. Since she is in extreme hunger, ordering any number of bowls of ramen is fine.
[{"input": "2 1000000007", "output": "2\n \n\nLet the two kinds of toppings be A and B. Four types of ramen can be ordered:\n\"no toppings\", \"with A\", \"with B\" and \"with A, B\". There are two sets of ramen\nthat satisfy the conditions:\n\n * The following three ramen: \"with A\", \"with B\", \"with A, B\".\n * Four ramen, one for each type.\n\n* * *"}, {"input": "3 1000000009", "output": "118\n \n\nLet the three kinds of toppings be A, B and C. In addition to the four types\nof ramen above, four more types of ramen can be ordered, where C is added to\nthe above four. There are 118 sets of ramen that satisfy the conditions, and\nhere are some of them:\n\n * The following three ramen: \"with A, B\", \"with A, C\", \"with B, C\".\n * The following five ramen: \"no toppings\", \"with A\", \"with A, B\", \"with B, C\", \"with A, B, C\".\n * Eight ramen, one for each type.\n\nNote that the set of the following three does not satisfy the condition:\n\"'with A', 'with B', 'with A, B'\", because C is not on any of them.\n\n* * *"}, {"input": "50 111111113", "output": "1456748\n \n\nRemember to print the number of the sets modulo M. Note that these three\nsample inputs above are included in the test set for the partial score.\n\n* * *"}, {"input": "3000 123456791", "output": "16369789\n \n\nThis sample input is not included in the test set for the partial score."}]
Print the number of the sets of bowls of ramen that satisfy the conditions, disregarding order, modulo M. * * *
s199094830
Runtime Error
p03375
Input is given from Standard Input in the following format: N M
tmp = list(map(int, input().split())) n, c = tmp[0], tmp[1] xs, vs = [0], [] ans = [0] for i in range(n): tmp = list(map(int, input().split())) xs.append(tmp[0]) vs.append(tmp[1]) xs_rev, vs_rev = [0], [] for i in range(n): xs_rev.append(c - xs[-(i + 1)]) vs_rev.append(vs[-(i + 1)]) def findmax(v_data, x_data, m, mode=True): vs1 = [0] for i in range(m): if mode: vs1.append(vs1[-1] + v_data[i] - x_data[i + 1] + x_data[i]) else: vs1.append(vs1[-1] + v_data[i] - x_data[i + 1] * 2 + x_data[i] * 2) return max(vs1) ans.append(findmax(vs, xs, n)) ans.append(findmax(vs_rev, xs_rev, n)) sumv = [] for i in range(1, n - 1): sumv.append( findmax(vs[:i], xs[: i + 1], i) + findmax(vs_rev[: n - i], xs_rev[: n - i + 1], n - i, mode=False) ) if sumv != []: ans.append(max(sumv)) sumv = [] for i in range(1, n - 1): sumv.append( findmax(vs[:i], xs[: i + 1], i, mode=False) + findmax(vs_rev[: n - i], xs_rev[: n - i + 1], n - i) ) if sumv != []: ans.append(max(sumv)) print(max(ans))
Statement In "Takahashi-ya", a ramen restaurant, basically they have one menu: "ramen", but N kinds of toppings are also offered. When a customer orders a bowl of ramen, for each kind of topping, he/she can choose whether to put it on top of his/her ramen or not. There is no limit on the number of toppings, and it is allowed to have all kinds of toppings or no topping at all. That is, considering the combination of the toppings, 2^N types of ramen can be ordered. Akaki entered Takahashi-ya. She is thinking of ordering some bowls of ramen that satisfy both of the following two conditions: * Do not order multiple bowls of ramen with the exactly same set of toppings. * Each of the N kinds of toppings is on two or more bowls of ramen ordered. You are given N and a prime number M. Find the number of the sets of bowls of ramen that satisfy these conditions, disregarding order, modulo M. Since she is in extreme hunger, ordering any number of bowls of ramen is fine.
[{"input": "2 1000000007", "output": "2\n \n\nLet the two kinds of toppings be A and B. Four types of ramen can be ordered:\n\"no toppings\", \"with A\", \"with B\" and \"with A, B\". There are two sets of ramen\nthat satisfy the conditions:\n\n * The following three ramen: \"with A\", \"with B\", \"with A, B\".\n * Four ramen, one for each type.\n\n* * *"}, {"input": "3 1000000009", "output": "118\n \n\nLet the three kinds of toppings be A, B and C. In addition to the four types\nof ramen above, four more types of ramen can be ordered, where C is added to\nthe above four. There are 118 sets of ramen that satisfy the conditions, and\nhere are some of them:\n\n * The following three ramen: \"with A, B\", \"with A, C\", \"with B, C\".\n * The following five ramen: \"no toppings\", \"with A\", \"with A, B\", \"with B, C\", \"with A, B, C\".\n * Eight ramen, one for each type.\n\nNote that the set of the following three does not satisfy the condition:\n\"'with A', 'with B', 'with A, B'\", because C is not on any of them.\n\n* * *"}, {"input": "50 111111113", "output": "1456748\n \n\nRemember to print the number of the sets modulo M. Note that these three\nsample inputs above are included in the test set for the partial score.\n\n* * *"}, {"input": "3000 123456791", "output": "16369789\n \n\nThis sample input is not included in the test set for the partial score."}]