Submission #2170395
Source Code Expand
#include <bits/stdc++.h>
#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible" ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible" ) << endl
typedef long long ll;
using namespace std;
const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;
//long long int kaizyo(long long int hh){
// cmp=1;
//while(hh>1){
// cmp=(cmp*hh)%MOD;
//hh--;
//}
//return cmp;
//}
//while(x!=0){
//sum+=x%10;
// x/=10;
//}
//各桁の和
//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力
//s.find(w[i])==string::npos
//findの使い方
//for(int i=0;i<n;i++){
// b[i]=x%2;
//x/=2;
//}二進数
long long int n,cnt=1,ans=0,a[10000000],b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("snuke"),alphh("ABCDEFGHIJK"),s;
int main(void){
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
rep(i,n)cin >>a[i];
rep(i,n){
if(i+1==a[a[i]-1]){
ans++;
}
}
Cout(ans/2);
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Friendly Rabbits |
User |
asdf1 |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
1836 Byte |
Status |
AC |
Exec Time |
9 ms |
Memory |
1024 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 |
1 ms |
256 KB |
0_02.txt |
AC |
1 ms |
256 KB |
1_00.txt |
AC |
1 ms |
256 KB |
1_01.txt |
AC |
9 ms |
1024 KB |
1_02.txt |
AC |
9 ms |
1024 KB |
1_03.txt |
AC |
9 ms |
1024 KB |
1_04.txt |
AC |
9 ms |
1024 KB |
1_05.txt |
AC |
9 ms |
1024 KB |
1_06.txt |
AC |
9 ms |
1024 KB |
1_07.txt |
AC |
9 ms |
1024 KB |
1_08.txt |
AC |
4 ms |
512 KB |
1_09.txt |
AC |
8 ms |
896 KB |
1_10.txt |
AC |
7 ms |
768 KB |
1_11.txt |
AC |
2 ms |
384 KB |