제출 #581027

#제출 시각아이디문제언어결과실행 시간메모리
581027Koosha_mv전선 연결 (IOI17_wiring)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first #include "wiring.h" const int N=2e5+99; const ll inf=1e15+99; ll last[2],dp[N]; vector<pair<int,int>> A; ll solve0(vector<pair<int,int>> now){ if(now.size()==1) return inf; int cnt0=0,cnt1=0,last0=0,last1=0,ans=0; f(i,0,now.size()){ if(now[i].S==0){ cnt0++; last0=i; } else{ cnt1++; last1=i; } } if(cnt0==0 || cnt1==0 || (cnt0>1 && cnt1>1)) return inf; int x; if(cnt0==1) x=last0; else x=last1; f(i,0,now.size()) ans+=abs(now[x].F-now[i].F); return ans; } ll solve1(vector<pair<int,int>> now){ if(now[0].S==now.back().S) return inf; int cnt=0,ans=0,t0=0,t1; f(i,0,now.size()){ if(now[i].S==now[0].S) ans-=now[i].F; else ans+=now[i].F; if(i+1<now.size() && now[i].S!=now[i+1].S){ cnt++; t0=i+1; } } t1=now.size()-t0; if(cnt>1) return inf; if(t0>=t1){ ans+=(t0-t1)*now[t0].F; } else{ ans+=(t0-t1)*now[t0-1].F; } return ans; } ll min_total_length(vector<int> r,vector<int> b){ last[0]=-inf,last[1]=-inf; int n=r.size()+b.size(); for(auto x : r) A.pb({x,0}); for(auto x : b) A.pb({x,1}); A.pb({-1,-1}); sort(all(A)); f(i,1,A.size()){ vector<pair<int,int>> now; maxm(last[A[i].S],A[i].F); dp[i]=inf; minm(dp[i],dp[i-1]+A[i].F-last[A[i].S^1]); ll res=0; f_(j,i-1,1){ if(A[j].S==A[i].S) break; res+=A[i].F-A[j].F; minm(dp[i],dp[j-1]+res); } f_(j,i-1,0){ now.pb(A[j+1]); sort(all(now)); minm(dp[i],dp[j]+solve1(now)); } //eror(dp[i]); } return dp[A.size()-1]; } /* int32_t main(){ ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0); vector<pair<int,int>> now; //now.pb({1,0}); //now.pb({2,0}); //now.pb({3,1}); //now.pb({4,1}); //eror(solve1(now)); //cout<<min_total_length({1,2},{3,4}); cout<<min_total_length({1,2,3,7},{0,4,5,9,10}); }*/

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

wiring.cpp: In function 'long long int solve0(std::vector<std::pair<int, int> >)':
wiring.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   33 |  f(i,0,now.size()){
      |    ~~~~~~~~~~~~~~              
wiring.cpp:33:2: note: in expansion of macro 'f'
   33 |  f(i,0,now.size()){
      |  ^
wiring.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   47 |  f(i,0,now.size()) ans+=abs(now[x].F-now[i].F);
      |    ~~~~~~~~~~~~~~              
wiring.cpp:47:2: note: in expansion of macro 'f'
   47 |  f(i,0,now.size()) ans+=abs(now[x].F-now[i].F);
      |  ^
wiring.cpp: In function 'long long int solve1(std::vector<std::pair<int, int> >)':
wiring.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   53 |  f(i,0,now.size()){
      |    ~~~~~~~~~~~~~~              
wiring.cpp:53:2: note: in expansion of macro 'f'
   53 |  f(i,0,now.size()){
      |  ^
wiring.cpp:56:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   if(i+1<now.size() && now[i].S!=now[i+1].S){
      |      ~~~^~~~~~~~~~~
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   78 |  f(i,1,A.size()){
      |    ~~~~~~~~~~~~                
wiring.cpp:78:2: note: in expansion of macro 'f'
   78 |  f(i,1,A.size()){
      |  ^
wiring.cpp:13:28: error: no matching function for call to 'max(long long int&, int&)'
   13 | #define maxm(a,b) a=max(a,b)
      |                            ^
wiring.cpp:80:3: note: in expansion of macro 'maxm'
   80 |   maxm(last[A[i].S],A[i].F);
      |   ^~~~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
wiring.cpp:13:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   13 | #define maxm(a,b) a=max(a,b)
      |                            ^
wiring.cpp:80:3: note: in expansion of macro 'maxm'
   80 |   maxm(last[A[i].S],A[i].F);
      |   ^~~~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
wiring.cpp:13:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   13 | #define maxm(a,b) a=max(a,b)
      |                            ^
wiring.cpp:80:3: note: in expansion of macro 'maxm'
   80 |   maxm(last[A[i].S],A[i].F);
      |   ^~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
wiring.cpp:13:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 | #define maxm(a,b) a=max(a,b)
      |                            ^
wiring.cpp:80:3: note: in expansion of macro 'maxm'
   80 |   maxm(last[A[i].S],A[i].F);
      |   ^~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
wiring.cpp:13:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 | #define maxm(a,b) a=max(a,b)
      |                            ^
wiring.cpp:80:3: note: in expansion of macro 'maxm'
   80 |   maxm(last[A[i].S],A[i].F);
      |   ^~~~
wiring.cpp:73:6: warning: unused variable 'n' [-Wunused-variable]
   73 |  int n=r.size()+b.size();
      |      ^