Submission #890810
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:64000000")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979
#define x0 ikjnrmthklmnt
#define y0 lkrjhkltr
#define y1 ewrgrg
typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<Int, Int> PLL;
typedef pair<double, double> PDD;
typedef complex<double> base;
const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 20007;
const int MAXV = 100007;
const int MAXE = 100000;
const int ADD = 1000000;
const int MOD = 1000000007;
const int CNT = 800;
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("distance.in", "r", stdin);
//freopen("distance.out", "w", stdout);
//freopen("out.txt" , "w" , stdout);
int n;
cin >> n;
VI a(n);
FOR(i,0,n)
{ scanf("%d" , &a[i]);
--a[i];
}
int res = 0;
FOR(i,0,n)
{
if (a[a[i]] == i)
{
++res;
}
}
res /= 2;
cout << res << endl;
return 0;
}
Submission Info
Submission Time
2016-09-24 21:02:59+0900
Task
B - Friendly Rabbits
User
RomaWhite
Language
C++14 (GCC 5.4.1)
Score
200
Code Size
1690 Byte
Status
AC
Exec Time
12 ms
Memory
640 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:68:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
{ 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
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
11 ms
512 KB
1_10.txt
AC
9 ms
512 KB
1_11.txt
AC
4 ms
256 KB