Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


int n;
vector<int> v[10005];
int at[10005];

int bfs(int n,int m){
  if(n==m) return 1;
  if(at[n]!=0) return 0;
  at[n]=1;
  int c=0;
  for(int u:v[n]){
    c+=bfs(u,m);
  }
  return c;
}

void bfs2(int n,vector<int> e){
  auto itr = find(all(e), n);
  size_t index = distance( e.begin(), itr );
  
  if (index != e.size()) return 0;
  e.push_back(n);
  for(int u:v[n]){
    bfs(u,e);
  }
  return 0;
}



int main(){
  
  cin>>n;
  int p[n];
  mint s=0;
  rep(i,n){
    cin>>p[i];
    if(p[i]==-1) continue;
    p[i]--;
    rep(i,n) at[n]=0;
    if(bfs(i,p[i])==0){
      v[p[i]].push_back(i);
      v[i].push_back(p[i]);
      s++;
    }
  }
  vector<int> a[n];
  mint ans=1;
  rep(i,n){
    if(p[i]!=-1) continue;
    bfs2(a[i]);
    ans*=(mint)(a[i].size());
  }
  ans*=s;
  
  rep(i,n){
    mint sn=s;
    vector<int> an[n];
    rep(i,n) an[i]=a[i];
    if(p[i]!=-1) continue;
    Rep(j,n){
      if(i==j) continue;
      auto itr = find(all(a[i]), j);
      size_t index = distance( a[i].begin(), itr );
  
      if (index != a[i].size()) continue;
      
      sn++;
      rep(
  
  
}
  

Compiler output:
a.cc:125:12: error: macro "Rep" requires 3 arguments, but only 2 given
  125 |     Rep(j,n){
      |            ^
a.cc:4:9: note: macro "Rep" defined here
    4 | #define Rep(i,s,n) for(int i=s;i<n;i++)
      |         ^~~
a.cc:137:3: error: unterminated argument list invoking macro "rep"
  137 | 
      |   ^
a.cc: In function 'void bfs2(int, std::vector<int>)':
a.cc:85:33: error: return-statement with a value, in function returning 'void' [-fpermissive]
   85 |   if (index != e.size()) return 0;
      |                                 ^
a.cc:88:11: error: cannot convert 'std::vector<int>' to 'int'
   88 |     bfs(u,e);
      |           ^
      |           |
      |           std::vector<int>
a.cc:70:19: note:   initializing argument 2 of 'int bfs(int, int)'
   70 | int bfs(int n,int m){
      |               ~~~~^
a.cc:90:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
   90 |   return 0;
      |          ^
a.cc: In function 'int main()':
a.cc:108:8: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
  108 |       s++;
      |       ~^~
a.cc:115:13: error: cannot convert 'std::vector<int>' to 'int'
  115 |     bfs2(a[i]);
      |          ~~~^
      |             |
      |             std::vector<int>
a.cc:81:15: note:   initializing argument 1 of 'void bfs2(int, std::vector<int>)'
   81 | void bfs2(int n,vector<int> e){
      |           ~~~~^
a.cc:125:5: error: 'Rep' was not declared in this scope
  125 |     Rep(j,n){
      |     ^~~
a.cc:133:10: error: expected '}' at end of input
  133 |       rep(
      |          ^
a.cc:120:11: note: to match this '{'
  120 |   rep(i,n){
      |           ^
a.cc:133:10: error: expected '}' at end of input
  133 |       rep(
      |          ^
a.cc:95:11: note: to match this '{'
   95 | int main(){
      |           ^