제출 #1216472

#제출 시각아이디문제언어결과실행 시간메모리
1216472PenguinsAreCuteBodyguard (JOI21_bodyguard)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, q;
	cin >> n >> q;
	vector<long long> x1(n), y1(n), x2(n), y2(n), x, y;
	vector<int> c(n);
	for(int i=0;i<n;i++) {
		int t, a, b;
		cin >> t >> a >> b >> c[i];
		long long st = t, sx = a;
		long long et = t + abs(b - a), ex = b;
		x1[i] = st + sx;
		y1[i] = st - sx;
		x2[i] = et + ex;
		y2[i] = et - ex;
		x.push_back(x1[i]);
		x.push_back(x2[i]);
		y.push_back(y1[i]);
		y.push_back(y2[i]);
		c[i] /= 2;
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	long long dp[2*n][2*n], xdelta[2*n-1][2*n], ydelta[2*n][2*n-1];
	memset(xdelta,0,sizeof(xdelta));
	memset(ydelta,0,sizeof(ydelta));
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++) {
		x1[i] = lower_bound(x.begin(),x.end(),x1[i]) - x.begin();
		y1[i] = lower_bound(y.begin(),y.end(),y1[i]) - y.begin();
		x2[i] = lower_bound(x.begin(),x.end(),x2[i]) - x.begin();
		y2[i] = lower_bound(y.begin(),y.end(),y2[i]) - y.begin();
		assert(x1[i] == x2[i] || y1[i] == y2[i]);
		if(x1[i] == x2[i])
			for(int j=y1[i];j<y2[i];j++)
				ydelta[x1[i]][j] = max(ydelta[x1[i]][j], c[i]);
		else
			for(int j=x1[i];j<x2[i];j++)
				xdelta[j][y1[i]] = max(xdelta[j][y1[i]], c[i]);
		if(x1[i] == x2[i])
			for(int j=y1[i];j<y2[i];j++)
				ydelta[x1[i]][j] = max(ydelta[x1[i]][j], c[i] * (y[j+1] - y[j]));
		else
			for(int j=x1[i];j<x2[i];j++)
				xdelta[j][y1[i]] = max(xdelta[j][y1[i]], c[i] * (x[j+1] - x[j]));
	}
	for(int i=2*n;i--;)
		for(int j=2*n;j--;) {
			if(i<2*n-1)
				dp[i][j] = max(dp[i][j],dp[i+1][j]+xdelta[i][j]);
			if(j<2*n-1)
				dp[i][j] = max(dp[i][j],dp[i][j+1]+ydelta[i][j]);
		}
	while(q--) {
		int t, p;
		cin >> t >> p;
		int cx = t + p, cy = t - p;
		int gx = lower_bound(x.begin(),x.end(),cx) - x.begin();
		int gy = lower_bound(y.begin(),y.end(),cy) - y.begin();
		if(gx >= 2 * n || gy >= 2 * n)
			cout << "0\n";
		else {
			long long ans = dp[gx][gy];
			if(gx)
				for(int i=gy;i<2*n;i++)
					ans = max(ans,xdelta[gx-1][i] / (x[gx]-x[gx-1]) * (x[gx] - cx) + dp[gx][i]);
			if(gy)
				for(int i=gx;i<2*n;i++)
					ans = max(ans,ydelta[i][gy-1] / (y[gy]-y[gy-1]) * (y[gy] - cy) + dp[i][gy]);
			cout << ans << "\n";
		}
	}
}

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

bodyguard.cpp: In function 'int main()':
bodyguard.cpp:37:55: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   37 |                                 ydelta[x1[i]][j] = max(ydelta[x1[i]][j], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from bodyguard.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
bodyguard.cpp:37:55: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   37 |                                 ydelta[x1[i]][j] = max(ydelta[x1[i]][j], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from bodyguard.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
bodyguard.cpp:37:55: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   37 |                                 ydelta[x1[i]][j] = max(ydelta[x1[i]][j], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bodyguard.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
bodyguard.cpp:37:55: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |                                 ydelta[x1[i]][j] = max(ydelta[x1[i]][j], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bodyguard.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
bodyguard.cpp:37:55: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |                                 ydelta[x1[i]][j] = max(ydelta[x1[i]][j], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
bodyguard.cpp:40:55: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   40 |                                 xdelta[j][y1[i]] = max(xdelta[j][y1[i]], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from bodyguard.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
bodyguard.cpp:40:55: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   40 |                                 xdelta[j][y1[i]] = max(xdelta[j][y1[i]], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from bodyguard.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
bodyguard.cpp:40:55: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   40 |                                 xdelta[j][y1[i]] = max(xdelta[j][y1[i]], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bodyguard.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
bodyguard.cpp:40:55: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   40 |                                 xdelta[j][y1[i]] = max(xdelta[j][y1[i]], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from bodyguard.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
bodyguard.cpp:40:55: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   40 |                                 xdelta[j][y1[i]] = max(xdelta[j][y1[i]], c[i]);
      |                                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~