#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
#define print(l) for(auto i:l) cout<<i<<" ";cout<<endl;
#define input(t,l,n) vector<t>l(n);for(int i = 0;i<n;i++)cin>>l[i];
// #define int long long
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define all(l) l.begin(),l.end()
#define pii pair<int,int>
#define fi first
#define se second
const int M = 1e9+7;
const int inf = 1e18;
int bp(int x, int y, int p){
int res = 1;
x = x % p;
while (y > 0) {
if (y & 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
int MI(int n, int p){
return bp(n, p - 2, p);
}
int mul(int x,int y, int p){
return x * 1ull * y % p;
}
int di(int x,int y, int p){
return mul(x, MI(y, p), p);
}
const int N = 1e3+10;
int n , m , k , q;
int ans[N][N];
int A[N];
map<int,int>is;
void cal(int l,int r){
int m = (l+r)/2;
int x = A[m];
ans[m][m] = x;
is[m] = 1;
for(int i = m-1;i>=0;i--){
x = Secret(x,A[i]);
ans[i][m] = x;
}
x = A[m+1];
for(int i = m+1;i<n;i++){
// is[m] = 1;
ans[m+1][i] = x;
x = Secret(x,A[i]);
}
if(r-l == 1){
return;
}
cal(l,m);
cal(m,r);
}
void Init(int N1,int A1[]){
n = N1;
for(int i =0 ;i<n;i++){
A[i] = A1[i];
}
for(int i = 0;i<n;i++){
ans[i][i] = A[i];
}
cal(0,n-1);
}
int Query(int L,int R){
if(L == R){
return A[L];
}
for(int i = L;i<=R;i++){
if(ans[L][i]>=1 and ans[i+1][R] >= 1){
// cout<<ans[L][i]<<" "<<ans[i+1][R]<<endl;
return Secret(ans[L][i],ans[i+1][R]);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
secret.cpp:16:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
16 | const int inf = 1e18;
| ^~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:92:1: warning: control reaches end of non-void function [-Wreturn-type]
92 | }
| ^| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |