Submission #891675
Source Code Expand
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SIZE(x) (int((x).size()))
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define repd(i,r,l) for (int i=(r); i>=(l); i--)
#define rept(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#ifndef ONLINE_JUDGE
#define debug(x) { cerr<<#x<<" = "<<(x)<<endl; }
#else
#define debug(x) {}
#endif
int a[100010];
void lemon()
{
int n;
scanf("%d",&n);
rep(i,1,n) scanf("%d",&a[i]);
int cnt=0;
rep(i,1,n) if (a[a[i]]==i && a[a[a[i]]]==a[i]) cnt++;
printf("%d\n",cnt/2);
}
int main()
{
ios::sync_with_stdio(true);
#ifndef ONLINE_JUDGE
//freopen("b.in","r",stdin);
#endif
lemon();
return 0;
}
Submission Info
Submission Time
2016-09-24 21:07:11+0900
Task
B - Friendly Rabbits
User
sillycross
Language
C++14 (GCC 5.4.1)
Score
200
Code Size
908 Byte
Status
AC
Exec Time
13 ms
Memory
640 KB
Compile Error
./Main.cpp: In function ‘void lemon()’:
./Main.cpp:32:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:33:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,1,n) scanf("%d",&a[i]);
^
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
13 ms
640 KB
1_02.txt
AC
13 ms
640 KB
1_03.txt
AC
13 ms
640 KB
1_04.txt
AC
13 ms
640 KB
1_05.txt
AC
13 ms
640 KB
1_06.txt
AC
13 ms
640 KB
1_07.txt
AC
13 ms
640 KB
1_08.txt
AC
6 ms
384 KB
1_09.txt
AC
11 ms
512 KB
1_10.txt
AC
10 ms
512 KB
1_11.txt
AC
4 ms
256 KB