Submission #890842


Source Code Expand

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	cin>>n;
	vector<int> d(n);
	rep(i, n) cin>>d[i];
	rep(i, n) d[i]--;
	int res = 0;
	rep(i, n) if(i!=d[i] && d[d[i]]==i) res++;
	res /= 2;
	cout<<res<<endl;
	return 0;
}

Submission Info

Submission Time
Task B - Friendly Rabbits
User Lepton
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1361 Byte
Status AC
Exec Time 32 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 15
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 2 ms 256 KB
0_02.txt AC 2 ms 256 KB
1_00.txt AC 3 ms 256 KB
1_01.txt AC 30 ms 640 KB
1_02.txt AC 30 ms 640 KB
1_03.txt AC 32 ms 640 KB
1_04.txt AC 30 ms 640 KB
1_05.txt AC 30 ms 640 KB
1_06.txt AC 31 ms 640 KB
1_07.txt AC 31 ms 640 KB
1_08.txt AC 13 ms 384 KB
1_09.txt AC 25 ms 512 KB
1_10.txt AC 22 ms 512 KB
1_11.txt AC 7 ms 256 KB