Submission #737987

# Submission time Handle Problem Language Result Execution time Memory
737987 2023-05-08T04:18:00 Z anusha777 Secret (JOI14_secret) C++14
Compilation error
0 ms 0 KB
#include "secret.h"
#include <bits/stdc++.h>
#define fast 			ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL)
#define sz(x)			(int)((x).size())
#define pb				push_back
#define vi				vector<int>
#define vb				vector<bool>
#define vvb				vector<vb>
#define pi				pair<int,int>
#define vpi				vector<pi>
#define vvi				vector<vi>
#define vc				vector<char>
#define all(x)			x.begin(), x.end()
#define rall(x)			x.rbegin(), x.rend()
#define pbb()			pop_back()
#define f				first
#define s				second
#define ll				long long
//#define int				long long
#define ull				unsigned long long
#define line               cout<<"_____________________________"<<endl;
#define hash                cout<<"################"<<endl;
#define forr(i, a, b)      for(int i=a; i<b; i++)
using namespace std;
const int N=1e5+1, mod=1e9+7, inf=1e18+1;
vi a;
int n;
void Set(int x, int v, int i , int l, int r)
{
    if(r-l==1)
    {
        a[x]=v;
        return;
    }
    int m= (l+r)/2;
    if(i<m) Set(2*x+1, v, i, l , m)
    else Set(2*x+2, v, i, m , r);
    a[x]= Secret(a[2*x+1], a[2*x+2]);
}
void init(int m, int A[])
{
    n=1;
    while(n<m) n*=2;
    a.resize(2*n-1, -1);
    forr(i, 0, n) Set(0, A[i], i, 0, n);

}
int query(int x, int lx, int rx, int l, int r)
{
    if(l>=rx or lx>=r) return -1;
    if(l>=lx and r<=rx) return a[x];
    int mx= (lx+rx)/2;
    int v1= query(2*x+1, lx, mx, l, r), v2= query(2*x+2, mx, rx, l, r);
    if(v1!=-1 and v2!==-1) return Secret(v1, v2);
    if(v1==-1) return v2;
    return v1;
}
int Query(int l, int r)
{
    return query(0, 0, n, l, r+1);
}

Compilation message

secret.cpp:25:39: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   25 | const int N=1e5+1, mod=1e9+7, inf=1e18+1;
      |                                   ~~~~^~
secret.cpp: In function 'void Set(int, int, int, int, int)':
secret.cpp:36:36: error: expected ';' before 'else'
   36 |     if(i<m) Set(2*x+1, v, i, l , m)
      |                                    ^
      |                                    ;
   37 |     else Set(2*x+2, v, i, m , r);
      |     ~~~~                            
secret.cpp: In function 'int query(int, int, int, int, int)':
secret.cpp:54:23: error: expected primary-expression before '=' token
   54 |     if(v1!=-1 and v2!==-1) return Secret(v1, v2);
      |                       ^