답안 #219872

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
219872 2020-04-06T15:40:05 Z DanerZein Split the Attractions (IOI19_split) C++14
컴파일 오류
0 ms 0 KB
#include "split.h"
#include <bits/stdc++.h>
typedef vector<int> vi;
using namespace std;
int vis[100010];
vi pa;
void dfs(int u,int c){
  pa.push_back(u);
  if(pa.size()==c) return;
  vis[u]=1;
  for(int i=0;i<G[u].size();i++){
    if(G[u][i]==0){
      dfs(G[u][i],c);
    }
  }
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
  vector<vi> G;
  G.resize(n);
  vi aux;
  for(int i=0;i<p.size();i++){
    int u,v;
    u=p[i];
    v=q[i];
    G[v].push_back(u);
    G[u].push_back(v);
  }
  vector<int> r;
  r.resize(n);
  dfs(0,aux[1]);
  int k=0;
  for(int i=0;i<n;i++){
    if(pa[k]==i){
      r[i]=2;
      k++;
    }
  }
  pa.clear();
  for(int i=0;i<n;i++){
    if(vis[i]==0){
      dfs(i,aux[0]);
      if(ca<a){
	ca=0;
	pa.clear();
      }
      else{
	break;
      }
    }
  }
  if(pa.empty()){
    for(int i=0;i<n;i++){
      r[i]=0;
    }
  }
  else{
  k=0;
  for(int i=0;i<n;i++){
    if(pa[k]==i){
      r[i]=1;
      k++;
    }
    else{
      r[i]=3;
    }
  }
  }
  return r;
}

Compilation message

split.cpp:3:9: error: 'vector' does not name a type; did you mean 'wctob'?
 typedef vector<int> vi;
         ^~~~~~
         wctob
split.cpp:6:1: error: 'vi' does not name a type; did you mean 'vis'?
 vi pa;
 ^~
 vis
split.cpp: In function 'void dfs(int, int)':
split.cpp:8:3: error: 'pa' was not declared in this scope
   pa.push_back(u);
   ^~
split.cpp:11:17: error: 'G' was not declared in this scope
   for(int i=0;i<G[u].size();i++){
                 ^
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:18:10: error: 'vi' was not declared in this scope
   vector<vi> G;
          ^~
split.cpp:18:10: note: suggested alternative: 'vis'
   vector<vi> G;
          ^~
          vis
split.cpp:18:12: error: template argument 1 is invalid
   vector<vi> G;
            ^
split.cpp:18:12: error: template argument 2 is invalid
split.cpp:19:5: error: request for member 'resize' in 'G', which is of non-class type 'int'
   G.resize(n);
     ^~~~~~
split.cpp:20:6: error: expected ';' before 'aux'
   vi aux;
      ^~~
split.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<p.size();i++){
               ~^~~~~~~~~
split.cpp:25:8: error: invalid types 'int[int]' for array subscript
     G[v].push_back(u);
        ^
split.cpp:26:8: error: invalid types 'int[int]' for array subscript
     G[u].push_back(v);
        ^
split.cpp:30:9: error: 'aux' was not declared in this scope
   dfs(0,aux[1]);
         ^~~
split.cpp:33:8: error: 'pa' was not declared in this scope
     if(pa[k]==i){
        ^~
split.cpp:33:8: note: suggested alternative: 'a'
     if(pa[k]==i){
        ^~
        a
split.cpp:38:3: error: 'pa' was not declared in this scope
   pa.clear();
   ^~
split.cpp:38:3: note: suggested alternative: 'a'
   pa.clear();
   ^~
   a
split.cpp:42:10: error: 'ca' was not declared in this scope
       if(ca<a){
          ^~
split.cpp:42:10: note: suggested alternative: 'a'
       if(ca<a){
          ^~
          a