제출 #1055620

#제출 시각아이디문제언어결과실행 시간메모리
1055620LeaRouseSplit the Attractions (IOI19_split)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "split.h" #define fastio ios_base::sync_with_stdio(0); cin.tie(0); #define ll long long #define ff first #define ss second #define endl '\n' using namespace std; const int MAX=1e5+5; const int MOD=1e8+7; int R[MAX]; int A[MAX]; int B[MAX]; map<string,int>m; vector<int>v; bool vis[MAX]; int cont=0; void dfs(int u){ A[cont]=u; cont++; vis[u]=true; for(auto it:v[u]){ if(vis[it]) continue; dfs(it); } } vector<int> find_split(int N, int a, int b, int c, vector<int> p, vector<int> q) { int m=p.size(); for(int i=0;i<m;i++){ v[p[i]].push_back(q[i]); v[q[i]].push_back(p[i]); B[p[i]]++; B[q[i]]++; } bool awa=false; for(int i=0;i<N;i++){ if(B[i]==1){ dfs(i); awa=true; break; } } if(!awa) dfs(0); vector<int>ans(n); for(int i=0;i<a;i++){ ans[A[i]]=1; } for(int i=a;i<a+b;i++){ ans[A[i]]=2; } for(int i=a+b;i<a+b+c;i++){ ans[A[i]]=3; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

split.cpp: In function 'void dfs(int)':
split.cpp:23:20: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   23 |     for(auto it:v[u]){
      |                    ^
      |                    std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from split.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
split.cpp:23:20: error: 'end' was not declared in this scope; did you mean 'std::end'?
   23 |     for(auto it:v[u]){
      |                    ^
      |                    std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from split.cpp:1:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:32:17: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)p.std::vector<int>::operator[](((std::vector<int>::size_type)i))))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   32 |         v[p[i]].push_back(q[i]);
      |                 ^~~~~~~~~
split.cpp:33:17: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)q.std::vector<int>::operator[](((std::vector<int>::size_type)i))))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   33 |         v[q[i]].push_back(p[i]);
      |                 ^~~~~~~~~
split.cpp:48:20: error: 'n' was not declared in this scope
   48 |     vector<int>ans(n);
      |                    ^