Seeking Help with Reading Complex Inputs in Rust

Revision en9, by rizzgod_tourist, 2024-07-25 19:09:33

Hello Codeforces community,

I'm reaching out for help with a Rust programming issue that's been frustrating me for a while. As a beginner in Rust, I'm struggling to understand how to read complex inputs, especially when it comes to competitive programming.

I've been trying to learn Rust, but I'm finding it challenging to grasp the concept of input/output handling. I've watched YouTube tutorials, but they only cover basic examples like "Hello, World!" or reading simple integers , also i have tried exploring some of the udemy courses but they are teaching all the complex stuff but they are not telling how to read input . However, when it comes to more complex inputs, such as reading multiple test cases with varying input formats, I'm lost.

I've tried to convert my C++ code to Rust using AI-powered tools like Blackbox AI and ChatGPT, but the generated code doesn't work as expected. I've also used C++ to Rust converters, but the resulting code doesn't produce any output.

Here's my C++ code that I'm trying to convert to Rust:

c++ Code

The AI-generated Rust code is:

rust Code

However, this code is giving me an "idleness limit" error, which I've never seen before in C++ or Java.

If someone could provide guidance on how to read complex inputs in Rust or share a working code for this problem without using templates, I would greatly appreciate it. I'm eager to learn and understand the underlying concepts, rather than just copying and pasting code.I don't want to use templates , first i want to write the raw code i don't care about writing some more line of code but i want to know everything from scratch also when i will become somewhat decent then i will write my own template i don't want to blindly follow some template and simply say that reading input and output is complicated in rust.

I've searched for Rust submissions for this problem (https://codeforces.me/contest/1876/problem/A), but out of nearly 7,000 submissions, I only found 6-7 in Rust, and they were all using templates for reading inputs.

Please help me overcome this hurdle, and I'll be grateful for any resources or explanations that can aid my learning journey in Rust.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en9 English rizzgod_tourist 2024-07-25 19:09:33 5 (published)
en8 English rizzgod_tourist 2024-07-25 19:09:03 88
en7 English rizzgod_tourist 2024-07-25 19:06:02 95
en6 English rizzgod_tourist 2024-07-25 19:04:21 94
en5 English rizzgod_tourist 2024-07-25 19:02:34 5 Tiny change: 'n\n\n\n```\nuse std:' -> 'n\n\n\n``` Rust\nuse std:'
en4 English rizzgod_tourist 2024-07-25 19:01:47 14
en3 English rizzgod_tourist 2024-07-25 18:59:17 127 (saved to drafts)
en2 English rizzgod_tourist 2024-07-25 18:57:29 146
en1 English rizzgod_tourist 2024-07-25 18:45:40 4323 Initial revision (published)