Submission #1777543
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 | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 612 Byte |
Status | CE |
Compile Error
./Main.cpp:21:14: error: too many decimal points in number for i in 0..n { ^ ./Main.cpp:1:1: error: ‘use’ does not name a type use std::io; ^ ./Main.cpp:3:1: error: ‘fn’ does not name a type fn next_int() -> i64 { ^ ./Main.cpp:9:1: error: ‘fn’ does not name a type fn next_vec() -> Vec<i64> { ^ ./Main.cpp:15:1: error: ‘fn’ does not name a type fn main() { ^