Submission #891786


Source Code Expand

#include "bits/stdc++.h"
using namespace std;

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

const int INF = 1 << 29;

signed main() {
	int n; cin >> n;
	V v(n);
	rep(i, n)cin >> v[i];
	int ans = 0;
	rep(i, n) {
		if (v[v[i] - 1] - 1 == i) ans++;
	}
	cout << ans / 2 << endl;
	system("pause");
}

Submission Info

Submission Time
Task B - Friendly Rabbits
User tosaka2
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1008 Byte
Status AC
Exec Time 33 ms
Memory 888 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:17: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
  system("pause");
                 ^

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 4 ms 504 KB
0_01.txt AC 4 ms 504 KB
0_02.txt AC 4 ms 504 KB
1_00.txt AC 4 ms 500 KB
1_01.txt AC 32 ms 888 KB
1_02.txt AC 32 ms 888 KB
1_03.txt AC 33 ms 888 KB
1_04.txt AC 32 ms 888 KB
1_05.txt AC 32 ms 888 KB
1_06.txt AC 32 ms 888 KB
1_07.txt AC 32 ms 888 KB
1_08.txt AC 14 ms 632 KB
1_09.txt AC 27 ms 760 KB
1_10.txt AC 24 ms 760 KB
1_11.txt AC 8 ms 504 KB