提出 #892864


ソースコード 拡げる

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define x first
#define y second
#define pb push_back
#define PB pop_back()
#define iOS ios_base::sync_with_stdio(false)
#define sqr(a) (((a) * (a)))
#define all(a) a.begin() , a.end()
#define error(x) cerr << #x << " = " << (x) <<endl
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define L(x) ((x)<<1)
#define R(x) (((x)<<1)+1)
#define umap unordered_map
#define double long double
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef complex<double> point;
template <typename T> using os =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}
const int maxn = 1e5 + 100;
int a[maxn];
int main(){
	iOS;
	int n;
	cin >> n;
	For(i,0,n){
		cin >> a[i];
		-- a[i];
	}
	int ans = 0;
	For(i,0,n)
		if(i < a[i] && a[a[i]] == i)
			++ ans;
	cout << ans << endl;
	return 0;
}

提出情報

提出日時
問題 B - 仲良しうさぎ
ユーザ amd
言語 C++14 (GCC 5.4.1)
得点 200
コード長 1549 Byte
結果 AC
実行時間 11 ms
メモリ 640 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 15
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
0_00.txt AC 2 ms 256 KiB
0_01.txt AC 2 ms 256 KiB
0_02.txt AC 2 ms 256 KiB
1_00.txt AC 2 ms 256 KiB
1_01.txt AC 11 ms 640 KiB
1_02.txt AC 11 ms 640 KiB
1_03.txt AC 11 ms 640 KiB
1_04.txt AC 11 ms 640 KiB
1_05.txt AC 11 ms 640 KiB
1_06.txt AC 11 ms 640 KiB
1_07.txt AC 11 ms 640 KiB
1_08.txt AC 6 ms 384 KiB
1_09.txt AC 9 ms 640 KiB
1_10.txt AC 8 ms 512 KiB
1_11.txt AC 4 ms 384 KiB