Submission details
Task:3SUM
Sender:aalto26gm_047
Submission time:2026-10-19 17:17:33 +0300
Language:Rust (2021)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.02 sdetails
#100.02 sdetails
#110.02 sdetails
#120.02 sdetails
#130.02 sdetails
#140.02 sdetails
#150.02 sdetails
#160.02 sdetails
#170.02 sdetails
#180.02 sdetails
#190.02 sdetails
#200.02 sdetails
#210.02 sdetails
#220.02 sdetails
#230.00 sdetails

Code

#![allow(unused)]

use std::{collections::VecDeque, io};

fn take_tuple() -> (usize, usize) {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut it = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<usize>().unwrap());
    (it.next().unwrap(), it.next().unwrap())
}

fn dfs(u: usize, adj: &Vec<Vec<bool>>, visited: &mut Vec<bool>, goal: usize, path: &mut VecDeque<usize>,) -> usize {
    if u == goal {
        path.push_back(u);
        return 1;
    }
    visited[u] = true;

    for i in (0..adj[u].len()).rev() {
        if adj[u][i] && !visited[i] {
            let f = dfs(i, adj, visited, goal, path);
            if f > 0 {
                path.push_back(u);
                return f;
            }
        }
    }
    0
}

fn main() {
    let (n, m): (usize, usize) = take_tuple();
    let mut adj: Vec<Vec<bool>> = vec![vec![true; n]; n];

    for _ in 0..m {
        let (a, b) = take_tuple();
        adj[a-1][b-1] = false;
        adj[b-1][a-1] = false;
    }

    let mut visited: Vec<bool> = vec![false; n];
    let start = 0;
    let mut path: VecDeque<usize> = VecDeque::new();
    let f = dfs(start, &adj, &mut visited, n-1, &mut path);

    if f == 0 {
        println!("0");
        return;
    }

    println!("{}", path.len());
    while !path.is_empty() {
        print!("{} ", path.pop_back().unwrap() + 1);
    }
}

Test details

Test 1

Verdict:

input
1 3
1

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:36:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 2

Verdict:

input
3 5
1 3 2

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 3

Verdict:

input
3 6
1 3 2

correct output
1 3 2

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 4

Verdict:

input
3 7
3 2 1

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 5

Verdict:

input
7 3
2 1 1 2 2 1 1

correct output
2 3 7

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 6

Verdict:

input
7 4
1 1 2 2 1 2 1

correct output
1 2 6

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 7

Verdict:

input
7 5
1 2 1 2 2 1 1

correct output
1 2 5

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 8

Verdict:

input
7 6
2 1 1 1 1 2 2

correct output
1 6 7

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 9

Verdict:

input
5000 3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1 2 5000

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 10

Verdict:

input
5000 4
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 11

Verdict:

input
5000 6
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
714 3518 4240

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 12

Verdict:

input
5000 919900245
663612758 9075403 585385629 98...

correct output
2787 465 2266

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:40:12:
index out of bounds: the len is 5000 but the index is 663612757
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 13

Verdict:

input
5000 999989608
12983 25966 38949 51932 64915 ...

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:40:12:
index out of bounds: the len is 5000 but the index is 12982
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 14

Verdict:

input
5000 1000000000
65536 131072 196608 262144 327...

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:40:12:
index out of bounds: the len is 5000 but the index is 65535
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 15

Verdict:

input
5000 642700000
6427 12854 19281 25708 32135 3...

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:40:12:
index out of bounds: the len is 5000 but the index is 6426
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 16

Verdict:

input
5000 919900246
663612758 9075403 585385629 98...

correct output
193 1698 4019

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:40:12:
index out of bounds: the len is 5000 but the index is 663612757
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 17

Verdict:

input
5000 919900247
663612758 9075403 585385629 98...

correct output
4258 470 1911

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:40:12:
index out of bounds: the len is 5000 but the index is 663612757
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 18

Verdict:

input
5000 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 ...

correct output
4998 4999 5000

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 19

Verdict:

input
5000 919900247
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 20

Verdict:

input
4999 919900245
9075403 585385629 987230075 83...

correct output
2786 464 2265

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:40:12:
index out of bounds: the len is 4999 but the index is 9075402
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 21

Verdict:

input
5000 1000000000
261323261 25262018 237798562 3...

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:40:12:
index out of bounds: the len is 5000 but the index is 261323260
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 22

Verdict:

input
5000 76305003
1 5088 10175 15262 20349 25436...

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:40:17:
index out of bounds: the len is 5000 but the index is 5087
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Test 23

Verdict:

input
2 6
2 2

correct output
IMPOSSIBLE

user output
(empty)

Error:
thread 'main' panicked at input/code.rs:12:16:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace