답안 #111799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111799 2019-05-16T07:54:24 Z AMO5 Two Antennas (JOI19_antennas) C++
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define all(x) (x).begin(), (x).end() 

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

long long INF=numeric_limits<long long>::max();

ll n,h,a,b,q,lft,rgt;
ll hgt[200222];
pll rng[200222];
vll adj[2002];
ll cost[2002][2002];

int check(int i, int j)
{
	
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    cin >> n;
    for(ll i=0; i<n; i++){
		cin >> h >> a >> b;
		hgt[i] = h;
		//left
		for(ll j=a; j<=b; j++){
			if(i-j>=0){
				adj[i-j].pb(i);
			}
			else break;
		}
		//right
		for(ll j=a; j<=b; j++){
			if(i+j<n){
				adj[i+j].pb(i);
			}
			else break;
		}
	}
	/*
	cout << " *** " << endl;
	for(int i=0; i<n; i++){
		for(int j=0; j<adj[i].size(); j++){
			cout << adj[i][j] << " " ;
		}
		cout << endl;
	}
	cout << " *** " << endl;
	*/

	for(int i=0; i<n; i++){
		for(int j = i+1; j<n; j++){
			if(binary_search(adj[i].begin(),adj[i].end(),j)&&binary_search(adj[j].begin(),adj[j].end(),i)){
				cost[i][j] = abs(hgt[i] - hgt[j]);
			}
		}
	}
	
	cin >> q;
	for(ll i=0; i<q; i++){
		ll ans = -1;
		cin >> lft >> rgt;
		lft--; rgt--;
		for(ll j=lft; j<=rgt; j++){
			for(ll k=j+1; k<=rgt; k++){
				if(cost[j][k])x`ans = max(cost[j][k],ans);
			}
		}
		cout << ans << endl;
	}
}	

Compilation message

antennas.cpp:90:20: error: stray '`' in program
     if(cost[j][k])x`ans = max(cost[j][k],ans);
                    ^
antennas.cpp: In function 'int check(int, int)':
antennas.cpp:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
antennas.cpp: In function 'int main()':
antennas.cpp:90:19: error: 'x' was not declared in this scope
     if(cost[j][k])x`ans = max(cost[j][k],ans);
                   ^