#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 200005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t,tree[li*4],tree1[li*4];
int cev;
string s;
vector<int> v;
inline void build(int node,int start,int end){
if(start>end)return ;
if(start==end){tree[node]=a[start]*(a[start]%2==0?-1:1);return ;}
build(node*2,start,mid),build(node*2+1,mid+1,end);
tree[node]=max(tree[node*2],tree[node*2+1]);
}
inline void build1(int node,int start,int end){
if(start>end)return ;
if(start==end){tree1[node]=a[start]*(a[start]%2==0?-1:1);return ;}
build1(node*2,start,mid),build1(node*2+1,mid+1,end);
tree1[node]=min(tree1[node*2],tree1[node*2+1]);
}
inline int query(int node,int start,int end,int l,int r){
if(start>end || start>r || end<l)return -inf;
if(start>=l && end<=r){return tree[node];}
return max(query(node*2,start,mid,l,r),query(node*2+1,mid+1,end,l,r));
}
inline int query1(int node,int start,int end,int l,int r){
if(start>end || start>r || end<l)return inf;
if(start>=l && end<=r){return tree1[node];}
return min(query1(node*2,start,mid,l,r),query1(node*2+1,mid+1,end,l,r));
}
main(void){
scanf("%lld",&n);
FOR{
scanf("%lld",&a[i]);
}
scanf("%lld",&t);
build(1,1,n);
build1(1,1,n);
while(t--){
int type,x,y,val;
scanf("%lld %lld %lld",&type,&x,&y);
if(type==1){
int say=-query1(1,1,n,x,y);
int say1=query(1,1,n,x,y);
if(say%2==1 || say==-inf || say<0)say=-1;
if(say1%2==0 || say1==-inf || say1<0)say1=-1;
printf("%lld %lld\n",say,say1);
}
}
return 0;
}
Compilation message
subway.cpp:57:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(void){
^
subway.cpp: In function 'int main()':
subway.cpp:66:16: warning: unused variable 'val' [-Wunused-variable]
int type,x,y,val;
^~~
subway.cpp:58:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&n);
~~~~~^~~~~~~~~~~
subway.cpp:60:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&a[i]);
~~~~~^~~~~~~~~~~~~~
subway.cpp:62:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&t);
~~~~~^~~~~~~~~~~
subway.cpp:67:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld",&type,&x,&y);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
201 ms |
7440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |