이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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();
int n,h,a,b,q,lft,rgt;
int hgt[200222];
pll rng[200222];
vector<int> adj[200222];
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(int i=0; i<n; i++){
cin >> h >> a >> b;
hgt[i] = h;
//left
for(int j=a; j<=b; j++){
if(i-j>=0){
adj[i-j].pb(i);
}
else break;
}
//right
for(int 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;
*/
cin >> q;
for(int i=0; i<q; i++){
int ans = -1;
cin >> lft >> rgt;
lft--; rgt--;
for(int j=lft; j<=rgt; j++){
for(int k=j+1; k<=rgt; k++){
if(binary_search(adj[j].begin(),adj[j].end(),k)&&binary_search(adj[k].begin(),adj[k].end(),j)){
ans = max(ans, abs(hgt[j]-hgt[k]));
//cout << j << " " << k << " " << hgt[j]-hgt[k] << endl;
}
}
}
cout << ans << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
antennas.cpp: In function 'int check(int, int)':
antennas.cpp:38:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |