CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus (Partitioning)
Sender:Zatzou
Submission time:2021-10-09 18:11:32
Language:Rust
Status:COMPILE ERROR

Compiler report

error[E0658]: non-ascii idents are not fully supported
 --> input/code.rs:6:13
  |
6 |     let mut määrät: u128 = 0;
  |             ^^^^^^
  |
  = note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more information

error[E0658]: non-ascii idents are not fully supported
  --> input/code.rs:13:5
   |
13 |     määrät += s.len() as u128;
   |     ^^^^^^
   |
   = note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more information

error[E0658]: non-ascii idents are not fully supported
  --> input/code.rs:17:9
   |
17 |     for väli in 2..=s.len() {
   |         ^^^^
   |
   = note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more information

error[E0658]: non-ascii idents are not fully supported
  --> input/code.rs:20:34
   |
20 |         while kohta <= s.len() - väli {
   |                                  ^^^^
   |
   = note: see issue #55467 <https://github.com/rust-lang/rust/issues/55467> for more in

Code

use std::io::stdin;

const MODULOLUKU: u128 = 1000000007;

fn main() {
    let mut määrät: u128 = 0;

    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();

    let s = s.trim();

    määrät += s.len() as u128;

    let merkit = s.as_bytes();

    for väli in 2..=s.len() {
        let mut kohta = 0;

        while kohta <= s.len() - väli {
            let mut kirjaimet = merkit[kohta..kohta+väli].to_owned();

            kirjaimet.sort();
            kirjaimet.dedup();

            if kirjaimet.len() == väli {
                määrät += 1;
            }

            kohta += 1;
        }
    }

    println!("{}", määrät % MODULOLUKU)
}