Submission #70252070
Source Code Expand
Q=int(input())
S=""
def isvalid(string):
score=0
for s in string:
if s=="(":
score+=1
elif s==")":
score-=1
if score<0:
return 0
return score==0
for _ in range(Q):
q=input()
if q[0]=="1":
S+=q[-1]
#print(S)
else:
S=S[:-1]
#print(S)
#良い括弧列かどうか判定
if isvalid(S):
print("Yes")
else:
print("No")
Submission Info
| Submission Time | |
|---|---|
| Task | C - Brackets Stack Query |
| User | shaptel |
| Language | Python (PyPy 3.10-v7.3.12) |
| Score | 0 |
| Code Size | 492 Byte |
| Status | TLE |
| Exec Time | 3326 ms |
| Memory | 317648 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 300 | ||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt |
| All | 00_sample_00.txt, 01_small_00.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 03_corner_00.txt, 03_corner_01.txt, 03_corner_02.txt, 03_corner_03.txt, 03_corner_04.txt, 03_corner_05.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 56 ms | 76264 KiB |
| 01_small_00.txt | AC | 741 ms | 83936 KiB |
| 02_random_00.txt | AC | 1175 ms | 84064 KiB |
| 02_random_01.txt | AC | 1208 ms | 83500 KiB |
| 02_random_02.txt | AC | 1227 ms | 83612 KiB |
| 02_random_03.txt | AC | 1228 ms | 84508 KiB |
| 02_random_04.txt | AC | 1178 ms | 83724 KiB |
| 02_random_05.txt | AC | 1292 ms | 84096 KiB |
| 02_random_06.txt | AC | 1195 ms | 84128 KiB |
| 02_random_07.txt | AC | 1374 ms | 85252 KiB |
| 02_random_08.txt | AC | 1205 ms | 83896 KiB |
| 02_random_09.txt | AC | 1217 ms | 84600 KiB |
| 03_corner_00.txt | TLE | 3315 ms | 101792 KiB |
| 03_corner_01.txt | TLE | 3326 ms | 317648 KiB |
| 03_corner_02.txt | TLE | 3316 ms | 105008 KiB |
| 03_corner_03.txt | TLE | 3326 ms | 317432 KiB |
| 03_corner_04.txt | TLE | 3316 ms | 105936 KiB |
| 03_corner_05.txt | TLE | 3316 ms | 105788 KiB |