Submission #1777544
Source Code Expand
use std::io; fn next_int() -> i64 { let mut buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); buf.trim().parse().unwrap() } fn next_vec() -> Vec<i64> { let mut buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); buf.split_whitespace().map(|n| n.parse().unwrap()).collect() } fn main() { let n = next_int(); let a = next_vec(); let mut cnt = 0; for i in 0..n { let idx = i as usize; let idx2 = a[idx] as usize; cnt += if a[idx2-1] == i + 1 {1} else {0}; } println!("{:?}", cnt/2); }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | nicklaw296 |
Language | Rust (1.15.1) |
Score | 200 |
Code Size | 612 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 6396 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 2 ms | 4352 KB |
0_01.txt | AC | 2 ms | 4352 KB |
0_02.txt | AC | 2 ms | 4352 KB |
1_00.txt | AC | 2 ms | 4352 KB |
1_01.txt | AC | 8 ms | 6396 KB |
1_02.txt | AC | 8 ms | 6396 KB |
1_03.txt | AC | 8 ms | 6396 KB |
1_04.txt | AC | 8 ms | 6396 KB |
1_05.txt | AC | 8 ms | 6396 KB |
1_06.txt | AC | 7 ms | 6396 KB |
1_07.txt | AC | 8 ms | 6396 KB |
1_08.txt | AC | 4 ms | 4352 KB |
1_09.txt | AC | 6 ms | 4352 KB |
1_10.txt | AC | 5 ms | 4352 KB |
1_11.txt | AC | 3 ms | 4352 KB |