Submission #891795


Source Code Expand

#include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define rep(i,n) for(int i=0,i##_len=n;i<i##_len;i++)
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;
using namespace std;

signed main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
  }
  int res = 0;
  rep(i, n){
    if(a[a[i]-1]-1 == i){
      res ++;
    }
  }
  cout << res/2 << endl;
}

Submission Info

Submission Time
Task B - Friendly Rabbits
User wass80
Language Ruby (2.3.3)
Score 0
Code Size 485 Byte
Status RE
Exec Time 10 ms
Memory 1916 KB

Compile Error

./Main.rb:19: syntax error, unexpected '{', expecting keyword_then or ';' or '\n'
    if(a[a[i]-1]-1 == i){
                         ^
./Main.rb:20: warning: `+' after local variable or literal is interpreted as binary operator
./Main.rb:20: warning: even though it seems like unary operator
./Main.rb:20: syntax error, unexpected ';'
      res ++;
             ^
./Main.rb:13: warning: possibly useless use of > in void context
./Main.rb:24: syntax error, unexpected end-of-input, expecting '}'

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
RE × 3
RE × 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 RE 10 ms 1788 KB
0_01.txt RE 10 ms 1788 KB
0_02.txt RE 10 ms 1788 KB
1_00.txt RE 10 ms 1788 KB
1_01.txt RE 10 ms 1788 KB
1_02.txt RE 10 ms 1788 KB
1_03.txt RE 10 ms 1788 KB
1_04.txt RE 10 ms 1788 KB
1_05.txt RE 10 ms 1788 KB
1_06.txt RE 10 ms 1788 KB
1_07.txt RE 10 ms 1916 KB
1_08.txt RE 10 ms 1788 KB
1_09.txt RE 10 ms 1788 KB
1_10.txt RE 10 ms 1788 KB
1_11.txt RE 10 ms 1788 KB