Submission #6941357
Source Code Expand
#include <bits/stdc++.h>
// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a ? a = b, 1 : 0; }
template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
//IN
void IN() {}
template<class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
cin >> head;
IN(forward<Tail>(tail)...);
}
//OUTS
template<size_t> struct int_{};
template<class Tuple, size_t Pos>
ostream& print_tuple(ostream& out, const Tuple& t, int_<Pos>) {
out << get<tuple_size<Tuple>::value-Pos>(t) << " ";
return print_tuple(out, t, int_<Pos-1>());
}
template <class Tuple>
ostream& print_tuple(ostream& out, const Tuple& t, int_<1>) {
return out << get<tuple_size<Tuple>::value-1>(t);
}
template<class... Args>
ostream& operator<<(ostream& out, const tuple<Args...>& t) {
return print_tuple(out, t, int_<sizeof...(Args)>());
}
#define OUTS(...) cout << make_tuple(__VA_ARGS__) << "\n";
//OUTL
void OUTL() {}
template<class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
cout << head << "\n";
OUTL(forward<Tail>(tail)...);
}
// }}} End
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
IN(n);
i64 res = 0;
map<int, int> mp;
reps(i, 1, n) {
int a; IN(a);
mp[i] = a;
if (mp[a] == i) ++res;
}
OUTL(res);
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Friendly Rabbits |
User |
r1933 |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
1762 Byte |
Status |
AC |
Exec Time |
54 ms |
Memory |
4992 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 |
1 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 |
53 ms |
4992 KB |
1_02.txt |
AC |
54 ms |
4992 KB |
1_03.txt |
AC |
52 ms |
4992 KB |
1_04.txt |
AC |
52 ms |
4992 KB |
1_05.txt |
AC |
51 ms |
4992 KB |
1_06.txt |
AC |
53 ms |
4992 KB |
1_07.txt |
AC |
52 ms |
4992 KB |
1_08.txt |
AC |
18 ms |
2048 KB |
1_09.txt |
AC |
42 ms |
4096 KB |
1_10.txt |
AC |
35 ms |
3584 KB |
1_11.txt |
AC |
8 ms |
1024 KB |