Submission #891124
Source Code Expand
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <vector> #include <string> #include <queue> #include <deque> #include <list> #include <stack> #include <set> #include <map> #include <algorithm> #define int long long #define MOD7 1000000007 #define MOD9 1000000009 #define rep(i, n) for (int i = 0; i < (n); i++) #define all(a) (a).begin(), (a).end() using namespace std; int dx[4] = { 1, 0, -1, 0 }; int dy[4] = { 0, -1, 0, 1 }; int nextInt() {int a; cin >> a; return a;} char nextChar() {char a; cin >> a; return a;} double nextDouble() {double a; cin >> a; return a;} string nextString() {string a; cin >> a; return a;} void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}} void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}} void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}} signed main() { int N; cin >> N; vector<int> a; inputVector(a, N); rep(i, N) a[i]--; int ret = 0; rep(i, N) { if (a[a[i]] == i) ret++; } cout << ret / 2 << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Friendly Rabbits |
User | iwashi31 |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 1193 Byte |
Status | AC |
Exec Time | 33 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 | 3 ms | 256 KB |
0_01.txt | AC | 3 ms | 256 KB |
0_02.txt | AC | 3 ms | 256 KB |
1_00.txt | AC | 3 ms | 256 KB |
1_01.txt | AC | 32 ms | 1400 KB |
1_02.txt | AC | 32 ms | 1400 KB |
1_03.txt | AC | 32 ms | 1400 KB |
1_04.txt | AC | 32 ms | 1400 KB |
1_05.txt | AC | 33 ms | 1400 KB |
1_06.txt | AC | 33 ms | 1400 KB |
1_07.txt | AC | 32 ms | 1400 KB |
1_08.txt | AC | 14 ms | 892 KB |
1_09.txt | AC | 27 ms | 1400 KB |
1_10.txt | AC | 24 ms | 1400 KB |
1_11.txt | AC | 8 ms | 640 KB |