Submission #890977


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];
set<int> b[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i),--a[i];
  REP(i,n)b[a[i]].insert(i);
  int ans = 0;
  REP(i,n)if(b[i].count(a[i]))++ans;
  ans/=2;
  cout<<ans<<endl;
  return 0;
}

Submission Info

Submission Time
Task B - Friendly Rabbits
User rickytheta
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1114 Byte
Status AC
Exec Time 36 ms
Memory 11136 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
                 ^
./Main.cpp:40:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i,n)scanf("%d",a+i),--a[i];
                                 ^

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 9 ms 6144 KB
0_01.txt AC 9 ms 6144 KB
0_02.txt AC 9 ms 6144 KB
1_00.txt AC 9 ms 6144 KB
1_01.txt AC 33 ms 11136 KB
1_02.txt AC 34 ms 11136 KB
1_03.txt AC 34 ms 11136 KB
1_04.txt AC 35 ms 11136 KB
1_05.txt AC 35 ms 11136 KB
1_06.txt AC 35 ms 11136 KB
1_07.txt AC 36 ms 11136 KB
1_08.txt AC 18 ms 8064 KB
1_09.txt AC 31 ms 10240 KB
1_10.txt AC 26 ms 9600 KB
1_11.txt AC 13 ms 6912 KB