#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#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 = 1000000000;
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 0;
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 0;
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));
}
int main(void){
scanf("%d",&n);
FOR{
scanf("%d",&a[i]);
}
scanf("%d",&t);
build(1,1,n);
build1(1,1,n);
while(t--){
int type,x,y,val;
scanf("%d %d %d",&type,&x,&y);
if(type==1){
printf("%d %d\n",-query1(1,1,n,x,y),query(1,1,n,x,y));
}
}
return 0;
}
Compilation message
subway.cpp: In function 'int main()':
subway.cpp:65:16: warning: unused variable 'val' [-Wunused-variable]
int type,x,y,val;
^~~
subway.cpp:57:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
subway.cpp:59:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[i]);
~~~~~^~~~~~~~~~~~
subway.cpp:61:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&t);
~~~~~^~~~~~~~~
subway.cpp:66:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d",&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 |
161 ms |
7380 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 |
- |