제출 #429001

#제출 시각아이디문제언어결과실행 시간메모리
429001REALITYNB전선 연결 (IOI17_wiring)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "wiring.h" #define int2 __int32 #define int long long #define all(a) a.begin(),a.end() #define pb push_back using namespace std; const int inf = 1e18 ; int min_total_length(vector<int2> r,vector<int2> bb){ vector<int> a ; for(int2&x:r) ++x ; for(int2&x: bb) ++x; for(int x:r) a.pb(x) ; for(int x:bb) a.pb(-x) ; sort(all(a),[&](int x,int y){return abs(x) <abs(y) ; }); int n = a.size() ; vector<vector<int>> b ; for(int i=0;i<n;i++){ int sz = 0 ; vector<int> hey ; for(int j=i;j<n;j++){ if(a[i]*a[j]<0) break ; hey.pb(j); i=j ; } b.pb(hey); } for(int&x:a)if(x<0) x*=-1 ; for(int&x:a) --x; /*cout << b.size() << endl ; for(auto x :b){ for(int y:x) cout << y << " "; cout << endl ; }*/ vector<int> dp(n,inf) ; int sumi = 0 ; for(int x:b[0]) sumi+=a[x] ; int loli = a[b[1][0]]*(b[0].size()) ; for(int i=0;i<b[1].size();i++){ loli+=a[b[1][i]]; if(i+1>b[0].size()){ sumi+=a[b[0].back()]; } else loli-=a[b[1][0]]; // cout << loli << " " << sumi << " "<< a[b[1][0]] << endl ; dp[b[1][i]]=loli-sumi ; } dp[b[0].back()]=dp[b[1][0]]; for(int i=2;i<b.size();i++){ int prev = dp[b[i-1].back()] ; int lol = b[i-1].back(); int sum = 0 ; for(int j=0;j<b[i].size();j++){ prev+=a[b[i][j]]; prev-=a[b[i-1].back()] ; if(lol-j>=b[i-1][0]){ sum+=a[b[i][j]]; sum-=a[lol-j]; prev=min(prev,dp[lol-j-1]+sum) ; } dp[b[i][j]]=min(dp[b[i][j]],prev) ; } int mn = min(b[i].size(),b[i-1].size()) ; prev=inf; sum = 0; for(int j=0;j<mn;j++) sum+=a[b[i][j]]; for(int j=b[i-1].size()-1;j>lol-mn;j--) sum-=a[b[i-1][j]]; for(int j=mn-1;j>-1;j--){ prev=min(prev,sum+dp[lol-j-1]) ; dp[b[i][j]]=min(dp[b[i][j]],prev) ; prev-=a[b[i][j]]; prev+=a[b[i][0]]; sum-=a[b[i][j]] ; sum+=a[lol-j]; } } // for(int x: dp) cout << x << " " ; return dp.back() ; }

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

wiring.cpp:3:14: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
    3 | #define int2 __int32
      |              ^~~~~~~
wiring.cpp:9:29: note: in expansion of macro 'int2'
    9 | int min_total_length(vector<int2> r,vector<int2> bb){
      |                             ^~~~
wiring.cpp:9:33: error: template argument 1 is invalid
    9 | int min_total_length(vector<int2> r,vector<int2> bb){
      |                                 ^
wiring.cpp:9:33: error: template argument 2 is invalid
wiring.cpp:3:14: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
    3 | #define int2 __int32
      |              ^~~~~~~
wiring.cpp:9:44: note: in expansion of macro 'int2'
    9 | int min_total_length(vector<int2> r,vector<int2> bb){
      |                                            ^~~~
wiring.cpp:9:48: error: template argument 1 is invalid
    9 | int min_total_length(vector<int2> r,vector<int2> bb){
      |                                                ^
wiring.cpp:9:48: error: template argument 2 is invalid
wiring.cpp: In function 'long long int min_total_length(int, int)':
wiring.cpp:3:14: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
    3 | #define int2 __int32
      |              ^~~~~~~
wiring.cpp:11:9: note: in expansion of macro 'int2'
   11 |     for(int2&x:r) ++x ;
      |         ^~~~
wiring.cpp:11:15: error: found ':' in nested-name-specifier, expected '::'
   11 |     for(int2&x:r) ++x ;
      |               ^
      |               ::
wiring.cpp:11:14: error: 'x' has not been declared
   11 |     for(int2&x:r) ++x ;
      |              ^
wiring.cpp:12:5: error: expected primary-expression before 'for'
   12 |     for(int2&x: bb) ++x;
      |     ^~~
wiring.cpp:11:24: error: expected ';' before 'for'
   11 |     for(int2&x:r) ++x ;
      |                        ^
      |                        ;
   12 |     for(int2&x: bb) ++x;
      |     ~~~                 
wiring.cpp:12:5: error: expected primary-expression before 'for'
   12 |     for(int2&x: bb) ++x;
      |     ^~~
wiring.cpp:11:24: error: expected ')' before 'for'
   11 |     for(int2&x:r) ++x ;
      |        ~               ^
      |                        )
   12 |     for(int2&x: bb) ++x;
      |     ~~~                 
wiring.cpp:12:15: error: found ':' in nested-name-specifier, expected '::'
   12 |     for(int2&x: bb) ++x;
      |               ^
      |               ::
wiring.cpp:12:14: error: 'x' has not been declared
   12 |     for(int2&x: bb) ++x;
      |              ^
wiring.cpp:13:5: error: expected primary-expression before 'for'
   13 |     for(int x:r) a.pb(x) ;
      |     ^~~
wiring.cpp:12:25: error: expected ';' before 'for'
   12 |     for(int2&x: bb) ++x;
      |                         ^
      |                         ;
   13 |     for(int x:r) a.pb(x) ;
      |     ~~~                  
wiring.cpp:13:5: error: expected primary-expression before 'for'
   13 |     for(int x:r) a.pb(x) ;
      |     ^~~
wiring.cpp:12:25: error: expected ')' before 'for'
   12 |     for(int2&x: bb) ++x;
      |        ~                ^
      |                         )
   13 |     for(int x:r) a.pb(x) ;
      |     ~~~                  
wiring.cpp:13:15: error: 'begin' was not declared in this scope
   13 |     for(int x:r) a.pb(x) ;
      |               ^
wiring.cpp:13:15: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from wiring.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
wiring.cpp:13:15: error: 'end' was not declared in this scope
   13 |     for(int x:r) a.pb(x) ;
      |               ^
wiring.cpp:13:15: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from wiring.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
wiring.cpp:14:15: error: 'begin' was not declared in this scope
   14 |     for(int x:bb) a.pb(-x) ;
      |               ^~
wiring.cpp:14:15: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from wiring.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
wiring.cpp:14:15: error: 'end' was not declared in this scope
   14 |     for(int x:bb) a.pb(-x) ;
      |               ^~
wiring.cpp:14:15: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from wiring.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
wiring.cpp:19:13: warning: unused variable 'sz' [-Wunused-variable]
   19 |         int sz = 0 ;
      |             ^~
wiring.cpp:39:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0;i<b[1].size();i++){
      |                 ~^~~~~~~~~~~~
wiring.cpp:41:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if(i+1>b[0].size()){
      |            ~~~^~~~~~~~~~~~
wiring.cpp:50:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i=2;i<b.size();i++){
      |                 ~^~~~~~~~~
wiring.cpp:54:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         for(int j=0;j<b[i].size();j++){
      |                     ~^~~~~~~~~~~~