Submission #877477

# Submission time Handle Problem Language Result Execution time Memory
877477 2023-11-23T09:17:14 Z serkanrashid Secret (JOI14_secret) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1024;

int n,a[maxn];
int pref[maxn][16],suff[maxn][16];
int idx;

void query(int l, int r, int lvl, int L, int R)
{
    int mid = (l+r)/2;
    if(L<=mid&&mid<=R)
    {
        idx = lvl;
        return;
    }
    if(R<mid) query(l,mid+0,lvl+1,L,R);
    else (mid+1,r,lvl+1,L,R);
}

int Query(int L, int R)
{
    L++;
    R++;
    idx = 0;
    query(1,n,1,L,R);
    int ans = pref[L][idx];
    if(L!=R) ans = Secret(ans,suff[R][idx]);
    return ans;
}

void divide(int l, int r, int lvl)
{
    int mid = (l+r)/2;
    pref[mid][lvl] = a[mid];
    for(int i=mid-1;i>=l;i--) pref[i][lvl] = Secret(a[i],pref[i+1][lvl]);
    if(mid!=r) suff[mid+1][lvl] = a[mid+1];
    for(int i=mid+2;i<=r;i++) suff[i][lvl] = Secret(suff[i-1][lvl],a[i]);
    if(l==r) return;
    divide(l,mid+0,lvl+1);
    divide(mid+1,r,lvl+1);
}

void Init(int N, int A[])
{
    n = N;
    for(int i=1;i<=n;i++) a[i] = A[i-1];
    divide(1,n,1);
}

/*int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

return 0;
}*/

Compilation message

secret.cpp: In function 'void query(int, int, int, int, int)':
secret.cpp:20:14: warning: left operand of comma operator has no effect [-Wunused-value]
   20 |     else (mid+1,r,lvl+1,L,R);
      |           ~~~^~
secret.cpp:20:23: warning: right operand of comma operator has no effect [-Wunused-value]
   20 |     else (mid+1,r,lvl+1,L,R);
      |                       ^
secret.cpp:20:22: warning: right operand of comma operator has no effect [-Wunused-value]
   20 |     else (mid+1,r,lvl+1,L,R);
      |                   ~~~^~
secret.cpp:20:27: warning: right operand of comma operator has no effect [-Wunused-value]
   20 |     else (mid+1,r,lvl+1,L,R);
      |                           ^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:30:20: error: 'Secret' was not declared in this scope
   30 |     if(L!=R) ans = Secret(ans,suff[R][idx]);
      |                    ^~~~~~
secret.cpp: In function 'void divide(int, int, int)':
secret.cpp:38:46: error: 'Secret' was not declared in this scope
   38 |     for(int i=mid-1;i>=l;i--) pref[i][lvl] = Secret(a[i],pref[i+1][lvl]);
      |                                              ^~~~~~
secret.cpp:40:46: error: 'Secret' was not declared in this scope
   40 |     for(int i=mid+2;i<=r;i++) suff[i][lvl] = Secret(suff[i-1][lvl],a[i]);
      |                                              ^~~~~~