답안 #624803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
624803 2022-08-08T18:35:23 Z CSQ31 유괴 2 (JOI17_abduction2) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
typedef pair<int,int> pii;
const int MAXN = 55555;
int a[MAXN],b[MAXN];
ll h,w,q;
typedef long long int ll;
map<int,ll>dp[2][MAXN];
ll solve(ll i,ll j,ll k){
	if(dp[k][i].find(j) != dp[k][i].end())return dp[k][i][j];
	dp[k][i][j] = -1e9;
	if(!k){
		for(ll jj=j+1;jj<w;jj++){
			if(b[jj] > a[i]){
				dp[0][i][j] = max(dp[0][i][j],solve(i,jj,1) + jj - j);
				break;
			}
		}
		for(ll jj=j-1;jj>=0;jj--){
			if(b[jj] > a[i]){
				dp[0][i][j] = max(dp[0][i][j],solve(i,jj,1) + j - jj);
				break;
			}
		}
		if(dp[0][i][j] == -1e9)dp[0][i][j] = max(w-1-j,j);
	}else{
		for(ll ii=i+1;ii<h;ii++){
			if(a[ii] > b[j]){
				dp[1][i][j] = max(dp[1][i][j],solve(ii,j,0) + ii - i);
				break;
			}
		}
		for(ll ii=i-1;ii>=0;ii--){
			if(a[ii] > b[j]){
				dp[1][i][j] = max(dp[1][i][j],solve(ii,j,0) + i - ii);
				break;
			}
		}
		if(dp[1][i][j] == -1e9)dp[1][i][j] = max(h-1-i,i);
	}
	return dp[k][i][j];
}
int main()
{
	owo
	cin>>h>>w>>q;
	for(int i=0;i<h;i++)cin>>a[i];
	for(int i=0;i<w;i++)cin>>b[i];
	while(q--){
		int i,j;
		cin>>i>>j;
		i--;
		j--;
		ll ans = max(solve(i,j,0),solve(i,j,1));
		cout<<ans<<'\n';
	}
	
}

Compilation message

abduction2.cpp:9:1: error: 'll' does not name a type
    9 | ll h,w,q;
      | ^~
abduction2.cpp: In function 'll solve(ll, ll, ll)':
abduction2.cpp:16:20: error: 'w' was not declared in this scope
   16 |   for(ll jj=j+1;jj<w;jj++){
      |                    ^
abduction2.cpp:28:44: error: 'w' was not declared in this scope
   28 |   if(dp[0][i][j] == -1e9)dp[0][i][j] = max(w-1-j,j);
      |                                            ^
abduction2.cpp:30:20: error: 'h' was not declared in this scope
   30 |   for(ll ii=i+1;ii<h;ii++){
      |                    ^
abduction2.cpp:42:44: error: 'h' was not declared in this scope
   42 |   if(dp[1][i][j] == -1e9)dp[1][i][j] = max(h-1-i,i);
      |                                            ^
abduction2.cpp: In function 'int main()':
abduction2.cpp:49:7: error: 'h' was not declared in this scope
   49 |  cin>>h>>w>>q;
      |       ^
abduction2.cpp:49:10: error: 'w' was not declared in this scope
   49 |  cin>>h>>w>>q;
      |          ^
abduction2.cpp:49:13: error: 'q' was not declared in this scope
   49 |  cin>>h>>w>>q;
      |             ^