Submission #653670

#TimeUsernameProblemLanguageResultExecution timeMemory
653670LitusianoConnecting Supertrees (IOI20_supertrees)C++14
Compilation error
0 ms0 KiB
int construct(vvi p){
  // Cap cami, components diferents
  // tots == 1, graf lineal
  // tots == 2, graf lineal amb el ultim unit al primer
  int N = p.size();
  
  vvi used(N,vi(N,0));
  if(n == 1){
    if(p[0][0] == 0){
      build(used); return 1;
    }
    return 0;
  } 
  vpi edges;
  /*For(i,N,0){
    For(j,N,0) cout<<p[i][j]<<" "; cout<<endl;
  }*/
  for(auto x : p){
    for(auto e : x){
      if(e == 3) return 0;
    }
  }
  For(i,N,0){
    For(j,N,0){
      if(used[i][j] || i == j) continue;
      //cout<<p[i][j]<<" "<<j<<endl;
      if(p[i][j] == 0) continue;
      //cout<<i<<" "<<j<<endl;
      // si tinc 1, vaig buscant 1ns sino dosos
      int cur = j;
      set<int> act;
      edges.pb({i,j});
      act.insert(i);
      used[i][j] = used[j][i] = 1;
      // Miro TOT EL CICLE
      int last = j;
      while(!act.count(cur)){
        act.insert(j);
        bool b = false;
        int nextcur = 0;
        For(k,N,0){
          //if(cur == j && k == i) continue;
          if(cur == 2){
            //cout<<"H "<<b<<" "<<k<<" "<<act.count(k)<<" "<<used[cur][k]<<endl;
            //for(auto x : act) cout<<x<<" "; cout<<"ENDH"<<endl;
          }
          if(act.count(k) && cur != k){
            if(p[k][cur] != p[cur][k] || p[cur][k] != p[i][j]){
              //cout<<"HERE "<<cur<<" "<<k<<" "<<i<<" "<<j<<" "<<p[i][j]<<" "<<p[cur][k]<<endl;
              return 0;
            }
          }
          
          else if(!act.count(k) && p[cur][k] == p[i][j] && !used[cur][k]){
            //cout<<i<<" "<<j<<" CUR "<<cur<<" "<<k<<endl;
            //for(auto x : act) cout<<x<<" "; cout<<endl;
            act.insert(k);
            for(auto x : act){
              used[x][k] = used[k][x] = 1;
            }
            b = 1;
            //afegir edge
            edges.pb({cur,k});
            used[cur][k] = 1;
            used[k][cur] = 1;
            last = cur;
            cur = k;
          }
        }
        //cur = nextcur;
      }
      //cout<<i<<" "<<j<<endl;
      //for(auto x : act) cout<<x<<" "; cout<<endl;
      if(p[i][j] == 2) edges.pb({last,i});
      if(act.size() == 2 && p[i][j] == 2){
        //cerr<<i<<" "<<j<<" "<<endl;
        //for(auto x : act) cerr<<x<<" "; cerr<<endl;
        return 0;
      }
    }
  }
  //cout<<"AAAAA"<<endl;
  //cerr<<edges.size()<<endl;
  vvi ans(N,vi(N,0));
  sort(all(edges));
  for(auto x : edges){
    //if(ans[x.f][x.s]) return 0;
    ans[x.f][x.s] = ans[x.s][x.f] = 1;
    //cerr<<x.f<<" "<<x.s<<endl;
  }
  build(ans);
  return 1;
}
 

Compilation message (stderr)

supertrees.cpp:1:15: error: 'vvi' was not declared in this scope
    1 | int construct(vvi p){
      |               ^~~