Submission #890799
Source Code Expand
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int a[SIZE];
int main(){
DRI(n);
REPP(i,1,n+1)RI(a[i]);
int an=0;
REPP(i,1,n+1){
if(a[a[i]]==i)an++;
}
printf("%d\n",an/2);
return 0;
}
Submission Info
Submission Time
2016-09-24 21:02:57+0900
Task
B - Friendly Rabbits
User
dreamoon
Language
C++14 (GCC 5.4.1)
Score
200
Code Size
1252 Byte
Status
AC
Exec Time
12 ms
Memory
640 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:32:11: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
DRI(n);
^
./Main.cpp:33:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REPP(i,1,n+1)RI(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
384 KB
1_00.txt
AC
2 ms
256 KB
1_01.txt
AC
12 ms
640 KB
1_02.txt
AC
12 ms
640 KB
1_03.txt
AC
12 ms
640 KB
1_04.txt
AC
12 ms
640 KB
1_05.txt
AC
12 ms
640 KB
1_06.txt
AC
12 ms
640 KB
1_07.txt
AC
12 ms
640 KB
1_08.txt
AC
6 ms
384 KB
1_09.txt
AC
10 ms
512 KB
1_10.txt
AC
9 ms
512 KB
1_11.txt
AC
4 ms
384 KB