| Task: | Company Queries II |
| Sender: | aalto26gh_003 |
| Submission time: | 2026-10-18 17:32:14 +0300 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.04 s | details |
| #2 | WRONG ANSWER | 0.04 s | details |
| #3 | WRONG ANSWER | 0.04 s | details |
| #4 | WRONG ANSWER | 0.04 s | details |
| #5 | WRONG ANSWER | 0.04 s | details |
| #6 | TIME LIMIT EXCEEDED | -- | details |
| #7 | WRONG ANSWER | 0.19 s | details |
| #8 | WRONG ANSWER | 0.37 s | details |
| #9 | TIME LIMIT EXCEEDED | -- | details |
| #10 | TIME LIMIT EXCEEDED | -- | details |
| #11 | WRONG ANSWER | 0.04 s | details |
| #12 | TIME LIMIT EXCEEDED | -- | details |
Code
import sys
def main():
data = map(int, sys.stdin.buffer.read().split())
it = iter(data)
n = next(it)
q = next(it)
bosses = [next(it) for _ in range(n - 1)]
print(n, q, bosses)
out = []
app = out.append
for _ in range(q):
a = next(it)
b = next(it)
s = set()
while a != 1:
s.add(a)
a = bosses[a - 2]
while b != 1 and b not in s:
b = bosses[b - 2]
if b == 1:
app("1")
else:
app(str(b))
print(" ".join(out))
main()
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 1 2 3 4 5 6 7 8 9 6 9 8 10 10 3 ... |
| correct output |
|---|
| 6 8 3 1 8 ... |
| user output |
|---|
| 10 10 [1, 2, 3, 4, 5, 6, 7, 8,... |
Feedback: Output is longer than expected
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 1 1 1 1 1 1 1 1 1 1 7 3 4 4 1 ... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 10 10 [1, 1, 1, 1, 1, 1, 1, 1,... |
Feedback: Output is longer than expected
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 1 1 1 1 2 3 4 4 1 1 8 2 7 8 3 ... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 10 10 [1, 1, 1, 1, 2, 3, 4, 4,... |
Feedback: Output is longer than expected
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 1 1 3 1 2 2 5 3 9 7 2 7 6 3 9 ... |
| correct output |
|---|
| 2 2 3 1 1 ... |
| user output |
|---|
| 10 10 [1, 1, 3, 1, 2, 2, 5, 3,... |
Feedback: Output is longer than expected
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 10 10 1 2 3 2 5 3 2 2 4 6 1 1 3 1 9 ... |
| correct output |
|---|
| 1 1 1 2 2 ... |
| user output |
|---|
| 10 10 [1, 2, 3, 2, 5, 3, 2, 2,... |
Feedback: Output is longer than expected
Test 6
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| 74862 8750 16237 72298 58111 ... |
| user output |
|---|
| (empty) |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 200000 200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
| correct output |
|---|
| 1 1 1 1 1 ... |
| user output |
|---|
| 200000 200000 [1, 1, 1, 1, 1, ... |
Feedback: Output is longer than expected
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 200000 200000 1 2 1 2 3 2 1 6 3 1 10 12 13 4... |
| correct output |
|---|
| 1 2 2 2 1 ... |
| user output |
|---|
| 200000 200000 [1, 2, 1, 2, 3, ... |
Feedback: Output is longer than expected
Test 9
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| 2796 633 633 151 2690 ... |
| user output |
|---|
| (empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 200000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| 365 73 103 365 216 ... |
| user output |
|---|
| (empty) |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 2 4 1 1 1 1 2 2 1 ... |
| correct output |
|---|
| 1 1 1 2 |
| user output |
|---|
| 2 4 [1] 1 1 1 2 |
Feedback: Output is longer than expected
Test 12
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 200000 1 1 2 3 4 5 6 7 8 9 10 11 12 1... |
| correct output |
|---|
| 27468 6353 27468 6353 6353 ... |
| user output |
|---|
| (empty) |
