Submission #890913


Source Code Expand

#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[100005];
int main(){
  cin>>n;
  REP(i,n) scanf("%d",&ar[i]),--ar[i];
  int res=0;
  REP(i,n) if(ar[ar[i]]==i) ++res;
  assert(res%2==0);
  cout<<res/2<<endl;
  return 0;
}


Submission Info

Submission Time
Task B - Friendly Rabbits
User hogloid
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1180 Byte
Status AC
Exec Time 13 ms
Memory 640 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:44:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i,n) scanf("%d",&ar[i]),--ar[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 3 ms 256 KB
0_01.txt AC 3 ms 256 KB
0_02.txt AC 3 ms 256 KB
1_00.txt AC 3 ms 256 KB
1_01.txt AC 13 ms 640 KB
1_02.txt AC 13 ms 640 KB
1_03.txt AC 13 ms 640 KB
1_04.txt AC 13 ms 640 KB
1_05.txt AC 13 ms 640 KB
1_06.txt AC 13 ms 640 KB
1_07.txt AC 13 ms 640 KB
1_08.txt AC 6 ms 384 KB
1_09.txt AC 11 ms 512 KB
1_10.txt AC 10 ms 512 KB
1_11.txt AC 4 ms 256 KB