CSES - Aalto Competitive Programming 2024 - wk7 - Mon - Results
Submission details
Task:Distinct Routes
Sender:Farah
Submission time:2024-10-21 16:31:16 +0300
Language:Python3 (CPython3)
Status:READY
Result:
Test results
testverdicttime
#10.02 sdetails
#20.02 sdetails
#30.02 sdetails
#40.02 sdetails
#5ACCEPTED0.02 sdetails
#60.02 sdetails
#70.02 sdetails
#80.02 sdetails
#90.02 sdetails
#100.02 sdetails
#110.02 sdetails
#120.02 sdetails
#130.02 sdetails
#140.02 sdetails
#150.02 sdetails

Code


def find_three_numbers(n, x, arr):
    indexed_arr = [(val, idx) for idx, val in enumerate(arr, start=1)]
    indexed_arr.sort()

    for i in range(n):
        first_value = indexed_arr[i][0]
        target_sum = x - first_value
        left = i + 1
        right = n - 1
        
        while left < right:
            current_sum = indexed_arr[left][0] + indexed_arr[right][0]
            if current_sum == target_sum:
                result = [indexed_arr[i][1], indexed_arr[left][1], indexed_arr[right][1]]
                result.sort()
                print(result[0], result[1], result[2])
                return
            elif current_sum < target_sum:
                left += 1
            else:
                right -= 1
    
    print("IMPOSSIBLE")

n, x = map(int, input().split())
arr = list(map(int, input().split()))

find_three_numbers(n, x, arr)

Test details

Test 1

Verdict:

input
2 1
1 2

correct output
1
2
1 2 

user output
IMPOSSIBLE

Test 2

Verdict:

input
4 2
1 2
3 4

correct output
0

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 3

Verdict:

input
500 996
1 2
2 500
1 3
3 500
...

correct output
498
3
1 2 500 
3
1 3 500 
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 4

Verdict:

input
500 499
1 2
2 3
3 4
4 5
...

correct output
1
500
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 5

Verdict: ACCEPTED

input
2 1
2 1

correct output
0

user output
IMPOSSIBLE

Test 6

Verdict:

input
40 1000
25 22
15 24
7 33
16 32
...

correct output
21
44
1 35 39 34 29 32 22 38 20 30 1...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 7

Verdict:

input
75 1000
72 6
46 66
63 45
70 46
...

correct output
12
30
1 29 24 9 18 63 45 31 66 72 6 ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 8

Verdict:

input
100 1000
75 97
7 62
88 25
36 44
...

correct output
9
51
1 35 15 86 79 34 43 94 83 75 9...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 9

Verdict:

input
3 2
1 2
2 3

correct output
1
3
1 2 3 

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 10

Verdict:

input
11 12
1 2
2 3
3 4
4 5
...

correct output
2
6
1 2 3 4 5 11 
7
1 6 7 8 9 10 11 

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 11

Verdict:

input
8 9
1 2
2 3
3 8
1 4
...

correct output
2
5
1 2 6 7 8 
5
1 4 5 3 8 

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 12

Verdict:

input
8 9
1 2
1 3
2 3
3 4
...

correct output
1
8
1 2 3 4 5 6 7 8 

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 13

Verdict:

input
7 9
1 2
1 3
2 7
3 4
...

correct output
3
3
1 2 7 
4
1 3 5 7 
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 14

Verdict:

input
7 15
3 6
5 2
5 4
3 5
...

correct output
2
5
1 2 3 6 7 
4
1 4 5 7 

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...

Test 15

Verdict:

input
500 986
244 252
224 22
81 484
273 432
...

correct output
116
5
1 129 142 473 500 
5
1 63 158 171 500 
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 30, in <module>
    f...