제출 #1139961

#제출 시각아이디문제언어결과실행 시간메모리
1139961Almonther기지국 (IOI20_stations)C++20
컴파일 에러
0 ms0 KiB
#include "stations.h" #include <bits/stdc++.h> #define ll long long #define co cout<< using namespace std; //stuff const ll maxn=1005; ll en[maxn],ou[maxn],a[maxn]; vector<ll>v1[maxn]; map<ll,ll>mp; ll tim=1; void dfs(ll x,ll last,ll dep){ en[x]=tim++; for(auto i:v1[x]){ if(i!=last) dfs(i,x,dep+1); } ou[x]=tim++; if(dep%2) mp[ou[x]],a[x]=ou[x]; else mp[en[x]],a[x]=en[x]; } vector<int>label(int n, int k, vector<int> u, vector<int> v){ for(int i=0;i<u.size();i++) v1[u[i]].push_back(v[i]); dfs(0,0,1); ll cnt=0; for(auto &i:mp) i.second=cnt,cnt++; vector<int>labels; for(int i=0;i<n;i++) labels.push_back(mp[a[i]]); mp={}; for(int i=0;i<n;i++) ou[i]=en[i]=a[i]=0,v1[i].clear(); tim=1; return labels; } int find_next_station(int s, int t, vector<int> c) { set<ll>s1; for(auto i:c) s1.insert(i); ll parent; ll l,r; if(s<*s1.begin()){ auto it=s1.end(); it--; parent=*it; s1.erase(it); it=s1.end(); it--; l=s; r=*it; co "wow\n"; if(!(l<=t&&t<=r)) return parent; // even i'm the ending time // they have the starting vector<ll>v; for(auto i:s1) v.push_back(i); for(int i=0;i<v.size()-1;i++){ if(v[i]<=t&&t<=v[i+1]) return v[i]; } return v.back(); } else{ parent=*s1.begin(); s1.erase(s1.begin()); l=*s1.begin(); r=s; if(!(l<=t&&t<=r)) return parent; // odd they have the finishing i have the starting vector<ll>v; for(auto i:s1) v.push_back(i); for(int i=v.size()-1;i>0;i--){ if(v[i]>=t&&t>=v[i-1]) return v[i]; } return v[0]; } } void check(){ } // int main(){ // vector<ll>v=label(5, 10, {0, 1, 1, 2}, {1, 2, 3, 4}); // for(int i=0;i<v.size();i++) co i<<' '<<v[i]<<'\n'; // co find_next_station(2,0,{1,0}); // // 2 // ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); // int _=1; // // cin>>_; // // while(_--) solve(); // return 0; // }#include "stations.h" #include <bits/stdc++.h> #define ll ll #define co cout<< using namespace std; //stuff const ll maxn=1005; ll en[maxn],ou[maxn],a[maxn]; vector<ll>v1[maxn]; map<ll,ll>mp; ll tim=1; void dfs(ll x,ll last,ll dep){ en[x]=tim++; for(auto i:v1[x]){ if(i!=last) dfs(i,x,dep+1); } ou[x]=tim++; if(dep%2) mp[ou[x]],a[x]=ou[x]; else mp[en[x]],a[x]=en[x]; } vector<int>label(int n, int k, vector<int> u, vector<int> v){ for(int i=0;i<u.size();i++) v1[u[i]].push_back(v[i]); dfs(0,0,1); ll cnt=0; for(auto &i:mp) i.second=cnt,cnt++; vector<int>labels; for(int i=0;i<n;i++) labels.push_back(mp[a[i]]); mp={}; for(int i=0;i<n;i++) ou[i]=en[i]=a[i]=0,v1[i].clear(); tim=1; return labels; } int find_next_station(int s, int t, vector<int> c) { set<ll>s1; for(auto i:c) s1.insert(i); ll parent; ll l,r; if(s<*s1.begin()){ auto it=s1.end(); it--; parent=*it; s1.erase(it); it=s1.end(); it--; l=s; r=*it; co "wow\n"; if(!(l<=t&&t<=r)) return parent; // even i'm the ending time // they have the starting vector<ll>v; for(auto i:s1) v.push_back(i); for(int i=0;i<v.size()-1;i++){ if(v[i]<=t&&t<=v[i+1]) return v[i]; } return v.back(); } else{ parent=*s1.begin(); s1.erase(s1.begin()); l=*s1.begin(); r=s; if(!(l<=t&&t<=r)) return parent; // odd they have the finishing i have the starting vector<ll>v; for(auto i:s1) v.push_back(i); for(int i=v.size()-1;i>0;i--){ if(v[i]>=t&&t>=v[i-1]) return v[i]; } return v[0]; } } void check(){ } // int main(){ // vector<ll>v=label(5, 10, {0, 1, 1, 2}, {1, 2, 3, 4}); // for(int i=0;i<v.size();i++) co i<<' '<<v[i]<<'\n'; // co find_next_station(2,0,{1,0}); // // 2 // ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); // int _=1; // // cin>>_; // // while(_--) solve(); // return 0; // }

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

stations.cpp:90: warning: "ll" redefined
   90 | #define ll ll
      | 
stations.cpp:4: note: this is the location of the previous definition
    4 | #define ll long long
      | 
stations.cpp:90:12: error: 'll' does not name a type
   90 | #define ll ll
      |            ^~
stations.cpp:94:7: note: in expansion of macro 'll'
   94 | const ll maxn=1005;
      |       ^~
stations.cpp:90:12: error: 'll' does not name a type
   90 | #define ll ll
      |            ^~
stations.cpp:95:1: note: in expansion of macro 'll'
   95 | ll en[maxn],ou[maxn],a[maxn];
      | ^~
stations.cpp:90:12: error: 'll' was not declared in this scope
   90 | #define ll ll
      |            ^~
stations.cpp:96:8: note: in expansion of macro 'll'
   96 | vector<ll>v1[maxn];
      |        ^~
stations.cpp:96:10: error: template argument 1 is invalid
   96 | vector<ll>v1[maxn];
      |          ^
stations.cpp:96:10: error: template argument 2 is invalid
stations.cpp:96:11: error: conflicting declaration 'int v1 [1005]'
   96 | vector<ll>v1[maxn];
      |           ^~
stations.cpp:10:11: note: previous declaration as 'std::vector<long long int> v1 [1005]'
   10 | vector<ll>v1[maxn];
      |           ^~
stations.cpp:90:12: error: 'll' was not declared in this scope
   90 | #define ll ll
      |            ^~
stations.cpp:97:5: note: in expansion of macro 'll'
   97 | map<ll,ll>mp;
      |     ^~
stations.cpp:90:12: error: 'll' was not declared in this scope
   90 | #define ll ll
      |            ^~
stations.cpp:97:8: note: in expansion of macro 'll'
   97 | map<ll,ll>mp;
      |        ^~
stations.cpp:97:10: error: template argument 1 is invalid
   97 | map<ll,ll>mp;
      |          ^
stations.cpp:97:10: error: template argument 2 is invalid
stations.cpp:97:10: error: template argument 3 is invalid
stations.cpp:97:10: error: template argument 4 is invalid
stations.cpp:97:11: error: conflicting declaration 'int mp'
   97 | map<ll,ll>mp;
      |           ^~
stations.cpp:11:11: note: previous declaration as 'std::map<long long int, long long int> mp'
   11 | map<ll,ll>mp;
      |           ^~
stations.cpp:90:12: error: 'll' does not name a type
   90 | #define ll ll
      |            ^~
stations.cpp:98:1: note: in expansion of macro 'll'
   98 | ll tim=1;
      | ^~
stations.cpp:99:6: error: variable or field 'dfs' declared void
   99 | void dfs(ll x,ll last,ll dep){
      |      ^~~
stations.cpp:90:12: error: 'll' was not declared in this scope
   90 | #define ll ll
      |            ^~
stations.cpp:99:10: note: in expansion of macro 'll'
   99 | void dfs(ll x,ll last,ll dep){
      |          ^~
stations.cpp:90:12: error: 'll' was not declared in this scope
   90 | #define ll ll
      |            ^~
stations.cpp:99:15: note: in expansion of macro 'll'
   99 | void dfs(ll x,ll last,ll dep){
      |               ^~
stations.cpp:90:12: error: 'll' was not declared in this scope
   90 | #define ll ll
      |            ^~
stations.cpp:99:23: note: in expansion of macro 'll'
   99 | void dfs(ll x,ll last,ll dep){
      |                       ^~
stations.cpp:108:12: error: redefinition of 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)'
  108 | vector<int>label(int n, int k, vector<int> u, vector<int> v){
      |            ^~~~~
stations.cpp:22:12: note: 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)' previously defined here
   22 | vector<int>label(int n, int k, vector<int> u, vector<int> v){
      |            ^~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:90:12: error: 'll' was not declared in this scope
   90 | #define ll ll
      |            ^~
stations.cpp:111:5: note: in expansion of macro 'll'
  111 |     ll cnt=0;
      |     ^~
stations.cpp:112:30: error: 'cnt' was not declared in this scope; did you mean 'int'?
  112 |     for(auto &i:mp) i.second=cnt,cnt++;
      |                              ^~~
      |                              int
stations.cpp: At global scope:
stations.cpp:120:5: error: redefinition of 'int find_next_station(int, int, std::vector<int>)'
  120 | int find_next_station(int s, int t, vector<int> c) {
      |     ^~~~~~~~~~~~~~~~~
stations.cpp:34:5: note: 'int find_next_station(int, int, std::vector<int>)' previously defined here
   34 | int find_next_station(int s, int t, vector<int> c) {
      |     ^~~~~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:90:12: error: 'll' was not declared in this scope
   90 | #define ll ll
      |            ^~
stations.cpp:121:9: note: in expansion of macro 'll'
  121 |     set<ll>s1;
      |         ^~
stations.cpp:121:11: error: template argument 1 is invalid
  121 |     set<ll>s1;
      |           ^
stations.cpp:121:11: error: template argument 2 is invalid
stations.cpp:121:11: error: template argument 3 is invalid
stations.cpp:122:22: error: request for member 'insert' in 's1', which is of non-class type 'int'
  122 |     for(auto i:c) s1.insert(i);
      |                      ^~~~~~
stations.cpp:123:8: error: expected ';' before 'parent'
  123 |     ll parent;
      |        ^~~~~~
stations.cpp:124:8: error: expected ';' before 'l'
  124 |     ll l,r;
      |        ^
stations.cpp:125:14: error: request for member 'begin' in 's1', which is of non-class type 'int'
  125 |     if(s<*s1.begin()){
      |              ^~~~~
stations.cpp:126:20: error: request for member 'end' in 's1', which is of non-class type 'int'
  126 |         auto it=s1.end();
      |                    ^~~
stations.cpp:128:9: error: 'parent' was not declared in this scope
  128 |         parent=*it;
      |         ^~~~~~
stations.cpp:129:12: error: request for member 'erase' in 's1', which is of non-class type 'int'
  129 |         s1.erase(it);
      |            ^~~~~
stations.cpp:130:15: error: request for member 'end' in 's1', which is of non-class type 'int'
  130 |         it=s1.end();
      |               ^~~
stations.cpp:132:9: error: 'l' was not declared in this scope
  132 |         l=s;
      |         ^
stations.cpp:133:9: error: 'r' was not declared in this scope
  133 |         r=*it;
      |         ^
stations.cpp:138:18: error: template argument 2 is invalid
  138 |         vector<ll>v;
      |                  ^
stations.cpp:139:20: error: 'begin' was not declared in this scope
  139 |         for(auto i:s1) v.push_back(i);
      |                    ^~
stations.cpp:139:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from stations.cpp:2:
/usr/include/c++/11/valarray:1228:5: note:   'std::begin'
 1228 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from stations.cpp:2:
/usr/include/c++/11/bits/ranges_base.h:561:44: note:   'std::ranges::__cust::begin'
  561 |     inline constexpr __cust_access::_Begin begin{};
      |                                            ^~~~~
In file included from /usr/include/c++/11/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from stations.cpp:2:
/usr/include/c++/11/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
In file included from /usr/include/c++/11/bits/stl_iterator_base_types.h:71,
                 from /usr/include/c++/11/bits/stl_algobase.h:65,
                 from /usr/include/c++/11/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/11/bits/iterator_concepts.h:949:10: note:   'std::ranges::__cust_access::begin'
  949 |     void begin(const auto&) = delete;
      |          ^~~~~
stations.cpp:139:20: error: 'end' was not declared in this scope
  139 |         for(auto i:s1) v.push_back(i);
      |                    ^~
stations.cpp:139:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from stations.cpp:2:
/usr/include/c++/11/valarray:1255:5: note:   'std::end'
 1255 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
In file included from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from stations.cpp:2:
/usr/include/c++/11/bits/ranges_base.h:562:42: note:   'std::ranges::__cust::end'
  562 |     inline constexpr __cust_access::_End end{};
      |                                          ^~~
In file included from /usr/include/c++/11/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from stations.cpp:2:
/usr/include/c++/11/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
In file included from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from stations.cpp:2:
/usr/include/c++/11/bits/ranges_base.h:136:10: note:   'std::ranges::__cust_access::end'
  136 |     void end(const auto&) = delete;
      |          ^~~
stations.cpp:139:26: error: request for member 'push_back' in 'v', which is of non-class type 'int'
  139 |         for(auto i:s1) v.push_back(i);
      |                          ^~~~~~~~~
stations.cpp:140:25: error: request for member 'size' in 'v', which is of non-class type 'int'
  140 |         for(int i=0;i<v.size()-1;i++){
      |                         ^~~~
stations.cpp:141:17: error: invalid types 'int[int]' for array subscript
  141 |             if(v[i]<=t&&t<=v[i+1]) return v[i];
      |                 ^
stations.cpp:141:29: error: invalid types 'int[int]' for array subscript
  141 |             if(v[i]<=t&&t<=v[i+1]) return v[i];
      |                             ^
stations.cpp:141:44: error: invalid types 'int[int]' for array subscript
  141 |             if(v[i]<=t&&t<=v[i+1]) return v[i];
      |                                            ^
stations.cpp:143:18: error: request for member 'back' in 'v', which is of non-class type 'int'
  143 |         return v.back();
      |                  ^~~~
stations.cpp:146:9: error: 'parent' was not declared in this scope
  146 |         parent=*s1.begin();
      |         ^~~~~~
stations.cpp:146:20: error: request for member 'begin' in 's1', which is of non-class type 'int'
  146 |         parent=*s1.begin();
      |                    ^~~~~
stations.cpp:147:12: error: request for member 'erase' in 's1', which is of non-class type 'int'
  147 |         s1.erase(s1.begin());
      |            ^~~~~
stations.cpp:147:21: error: request for member 'begin' in 's1', which is of non-class type 'int'
  147 |         s1.erase(s1.begin());
      |                     ^~~~~
stations.cpp:148:9: error: 'l' was not declared in this scope
  148 |         l=*s1.begin();
      |         ^
stations.cpp:148:15: error: request for member 'begin' in 's1', which is of non-class type 'int'
  148 |         l=*s1.begin();
      |               ^~~~~
stations.cpp:149:9: error: 'r' was not declared in this scope
  149 |         r=s;
      |         ^
stations.cpp:152:18: error: template argument 2 is invalid
  152 |         vector<ll>v;
      |                  ^
stations.cpp:153:20: error: 'begin' was not declared in this scope
  153 |         for(auto i:s1) v.push_back(i);
      |                    ^~
stations.cpp:153:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from stations.cpp:2:
/usr/include/c++/11/valarray:1228:5: note:   'std::begin'
 1228 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from stations.cpp:2:
/usr/include/c++/11/bits/ranges_base.h:561:44: note:   'std::ranges::__cust::begin'
  561 |     inline constexpr __cust_access::_Begin begin{};
      |                                            ^~~~~
In file included from /usr/include/c++/11/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from stations.cpp:2:
/usr/include/c++/11/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
In file included from /usr/include/c++/11/bits/stl_iterator_base_types.h:71,
                 from /usr/include/c++/11/bits/stl_algobase.h:65,
                 from /usr/include/c++/11/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/11/bits/iterator_concepts.h:949:10: note:   'std::ranges::__cust_access::begin'
  949 |     void begin(const auto&) = delete;
      |          ^~~~~
stations.cpp:153:20: error: 'end' was not declared in this scope
  153 |         for(auto i:s1) v.push_back(i);
      |                    ^~
stations.cpp:153:20: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from stations.cpp:2:
/usr/include/c++/11/valarray:1255:5: note:   'std::end'
 1255 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
In file included from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from stations.cpp:2:
/usr/include/c++/11/bits/ranges_base.h:562:42: note:   'std::ranges::__cust::end'
  562 |     inline constexpr __cust_access::_End end{};
      |                                          ^~~
In file included from /usr/include/c++/11/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:129,
                 from stations.cpp:2:
/usr/include/c++/11/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
In file included from /usr/include/c++/11/string_view:48,
                 from /usr/include/c++/11/bits/basic_string.h:48,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from stations.cpp:2:
/usr/include/c++/11/bits/ranges_base.h:136:10: note:   'std::ranges::__cust_access::end'
  136 |     void end(const auto&) = delete;
      |          ^~~
stations.cpp:153:26: error: request for member 'push_back' in 'v', which is of non-class type 'int'
  153 |         for(auto i:s1) v.push_back(i);
      |                          ^~~~~~~~~
stations.cpp:154:21: error: request for member 'size' in 'v', which is of non-class type 'int'
  154 |         for(int i=v.size()-1;i>0;i--){
      |                     ^~~~
stations.cpp:155:17: error: invalid types 'int[int]' for array subscript
  155 |             if(v[i]>=t&&t>=v[i-1]) return v[i];
      |                 ^
stations.cpp:155:29: error: invalid types 'int[int]' for array subscript
  155 |             if(v[i]>=t&&t>=v[i-1]) return v[i];
      |                             ^
stations.cpp:155:44: error: invalid types 'int[int]' for array subscript
  155 |             if(v[i]>=t&&t>=v[i-1]) return v[i];
      |                                            ^
stations.cpp:157:17: error: invalid types 'int[int]' for array subscript
  157 |         return v[0];
      |                 ^
stations.cpp: At global scope:
stations.cpp:160:6: error: redefinition of 'void check()'
  160 | void check(){
      |      ^~~~~
stations.cpp:74:6: note: 'void check()' previously defined here
   74 | void check(){
      |      ^~~~~