답안 #924681

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924681 2024-02-09T12:44:40 Z Dzadzo 전선 연결 (IOI17_wiring) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "wiring.h"
#define ll long long
#define int ll
#define pb push_back
#define S second
#define F first
#define pii pair<int,int>
#define vi vector <int>
#define vvi vector <vi>
#define vvvi vector <vvi>
#define vp vector <pii>
#define vvp vector <vp>
#define vb vector <bool>
#define vvb vector <vb>;
#define INF LLONG_MAX
#define MOD 1000000007
#define MAXN 100000
using namespace std;
long long min_total_length(std::vector<__int32> r, std::vector<__int32> b){
	vp v;
	v.pb({0,0});
	for (int x:r)v.pb({x,-1});
	for (int x:b)v.pb({x,1});
	int n=v.size()-1;
	sort(v.begin()+1,v.end());
	vi dp(n+1,INF),p(n+1);
	dp[0]=0;
	for (int i=1;i<=n;i++){
		p[i]=p[i-1]+v[i].F;
	}
	int cur=1,prev=0;
	while (v[prev].S==v[prev+1].S)cur++;
	int ind;
	for (int i=cur+1;i<=n;i++){
		if (v[i].S!=v[i-1].S){
			ind=v[i-1].F;
			for (int j=i-cur;j<i;j++)if (dp[j-1]!=INF)dp[j]=min(dp[j],dp[j-1]+v[i].F-v[j].F);
			prev=cur;
			cur=0;
		}
		cur++;
		if (dp[i-1]!=INF)
		dp[i]=min(dp[i],dp[i-1]+v[i].F-ind);
		if (cur<=prev && dp[i-2*cur]!=INF)dp[i]=min(dp[i],dp[i-2*cur]+p[i]+p[i-2*cur]-2*p[i-cur]);
	}
	return dp[n];
}

Compilation message

wiring.cpp:20:40: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
   20 | long long min_total_length(std::vector<__int32> r, std::vector<__int32> b){
      |                                        ^~~~~~~
      |                                        __rintf32
wiring.cpp:20:47: error: template argument 1 is invalid
   20 | long long min_total_length(std::vector<__int32> r, std::vector<__int32> b){
      |                                               ^
wiring.cpp:20:47: error: template argument 2 is invalid
wiring.cpp:20:64: error: '__int32' was not declared in this scope; did you mean '__rintf32'?
   20 | long long min_total_length(std::vector<__int32> r, std::vector<__int32> b){
      |                                                                ^~~~~~~
      |                                                                __rintf32
wiring.cpp:20:71: error: template argument 1 is invalid
   20 | long long min_total_length(std::vector<__int32> r, std::vector<__int32> b){
      |                                                                       ^
wiring.cpp:20:71: error: template argument 2 is invalid
wiring.cpp: In function 'long long int min_total_length(int, int)':
wiring.cpp:23:13: error: 'begin' was not declared in this scope
   23 |  for (int x:r)v.pb({x,-1});
      |             ^
wiring.cpp:23:13: 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:23:13: error: 'end' was not declared in this scope
   23 |  for (int x:r)v.pb({x,-1});
      |             ^
wiring.cpp:23:13: 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:24:13: error: 'begin' was not declared in this scope
   24 |  for (int x:b)v.pb({x,1});
      |             ^
wiring.cpp:24:13: 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:24:13: error: 'end' was not declared in this scope
   24 |  for (int x:b)v.pb({x,1});
      |             ^
wiring.cpp:24:13: 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
      |   ^~~