Submission #366659

# Submission time Handle Problem Language Result Execution time Memory
366659 2021-02-14T21:02:49 Z iliccmarko Secret (JOI14_secret) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
const int N = 1005;
int a[N][N];
int arr[N];
int n;

void build(int l, int r)
{
    if(r-l<=1) return;
    int mid = (l+r)/2;
    int val = arr[mid];
    for(int i = mid-1;i>=l;i--)
    {
        val = Secret(val, a[i]);
        a[i][mid] = val;
    }
    val = arr[mid+1];
    for(int i = mid+2;i<=r;i++)
    {
        val = Secret(val, a[i]);
        a[mid+1][i] = val;
    }
    build(l, mid);
    build(mid+1, r);
}

void Init(int N, int w[])
{
    n = N;
    for(int i = 0;i<n;i++)
        for(int j = 0;j<n;j++)
        a[i][j] = -1;
    for(int i = 0;i<n;i++) arr[i] = w[i];
    for(int i = 0;i<n;i++) a[i][i] = arr[i];
    build(0, n-1);
}

int resi(int l, int r)
{
    int mid = (l+r)/2;
    if(l<=mid&&r>mid)
    {
        return Secret(a[l][mid], a[mid+1][r]);
    }
    if(l>mid) return resi(mid+1, r);
    else return resi(l, mid);
}

int Query(int l, int r)
{
    if(a[l][r]!=-1) return a[l][r];
    if(l==r-1) return Secret(a[l], a[r]);
    return resi(l, r);
}

Compilation message

secret.cpp: In function 'void build(int, int)':
secret.cpp:28:30: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   28 |         val = Secret(val, a[i]);
      |                           ~~~^
      |                              |
      |                              int*
In file included from secret.cpp:2:
secret.h:7:23: note:   initializing argument 2 of 'int Secret(int, int)'
    7 | int Secret(int X, int Y);
      |                   ~~~~^
secret.cpp:34:30: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   34 |         val = Secret(val, a[i]);
      |                           ~~~^
      |                              |
      |                              int*
In file included from secret.cpp:2:
secret.h:7:23: note:   initializing argument 2 of 'int Secret(int, int)'
    7 | int Secret(int X, int Y);
      |                   ~~~~^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:66:33: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   66 |     if(l==r-1) return Secret(a[l], a[r]);
      |                              ~~~^
      |                                 |
      |                                 int*
In file included from secret.cpp:2:
secret.h:7:16: note:   initializing argument 1 of 'int Secret(int, int)'
    7 | int Secret(int X, int Y);
      |            ~~~~^
secret.cpp:66:39: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   66 |     if(l==r-1) return Secret(a[l], a[r]);
      |                                    ~~~^
      |                                       |
      |                                       int*
In file included from secret.cpp:2:
secret.h:7:23: note:   initializing argument 2 of 'int Secret(int, int)'
    7 | int Secret(int X, int Y);
      |                   ~~~~^