Submission #891122
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define int int_fast64_t signed main() { ios_base::sync_with_stdio(false), cin.tie(nullptr); int n; cin >> n; vector<int> v; copy_n(istream_iterator<int>(cin), n, back_inserter(v)); auto friendly = [&](int x) { return (v[x]-1 != x && v[v[x]-1]-1 == x); }; int s=0; for (int i=0; i<n; ++i) s += friendly(i); cout << s/2 << '\n'; } /* * Local variables: * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14 b.cc -o b && for f in *.in; do echo \"--- $f -------------\"; ./b <$f; done" * end: */
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | prugler |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 636 Byte |
Status | AC |
Exec Time | 12 ms |
Memory | 1400 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 | 256 KB |
0_01.txt | AC | 2 ms | 256 KB |
0_02.txt | AC | 2 ms | 256 KB |
1_00.txt | AC | 2 ms | 256 KB |
1_01.txt | AC | 12 ms | 1400 KB |
1_02.txt | AC | 12 ms | 1400 KB |
1_03.txt | AC | 12 ms | 1400 KB |
1_04.txt | AC | 12 ms | 1400 KB |
1_05.txt | AC | 12 ms | 1400 KB |
1_06.txt | AC | 12 ms | 1400 KB |
1_07.txt | AC | 12 ms | 1400 KB |
1_08.txt | AC | 6 ms | 892 KB |
1_09.txt | AC | 11 ms | 1400 KB |
1_10.txt | AC | 10 ms | 1400 KB |
1_11.txt | AC | 4 ms | 640 KB |