Submission #424056

#TimeUsernameProblemLanguageResultExecution timeMemory
424056SAADWall (IOI14_wall)C++17
Compilation error
0 ms0 KiB
#define F first
#define S second
#define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1))
#define pb push_back
#define Fbitl __builtin_ffs
#define bit1 __builtin_popcount
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
//#include "wall.h"
bool th ;
int seg[(int)1e6 + 1] , L , R , num ;
int n ;
void segmant ( int idx ) {
    if (idx >= n) return;
    int l = bit1(idx)-1 , r = l + (n/pow(2,(int)(log2(idx)))) - 1;
    if ( l >= L && r <= R ) {
        if ( th ) seg[idx] = (seg[idx]==-1?num:min(seg[idx],num));
        else seg[idx] = (seg[idx]==-1?num:max(seg[idx],num));
    }
    else if ( l > R || r < L ) return;
    else {
        segmant(idx*2);
        segmant((idx*2)+1);
    }
}
int mx ( int idx ) {
    if (idx==1) return seg[1];
    int res = max(seg[idx],mx(idx/2));
    return res;
}
int mn ( int idx ) {
    if (idx==1) return (seg[1]==-1?(int)1e6:seg[1]);
    int res = min((seg[idx]==-1?(int)1e6:seg[idx]),mn(idx/2));
    return res;
}

void buildWall(int n, int k, int op[], int left[], int right[],int height[], int& finalHeight[]) {
    //memset(seg,-1,sizeof(-1));
    //for (int i=n;i<n+n;i++) seg[i] = 0;
    ::n = n;
    int c = 0;
    while (op[c] == 1 && c < k) {
        num = height[c];L = left[c];R = right[c];
        segmant(1);
        c++;
    }
    for (int i=0;i<n;i++) finalHeight[i] = mx(i+n);
    memset(seg,-1,sizeof(seg));
    th = true;
    while (op[c] == 2 && c < k) {
        num = height[c];L = left[c];R = right[c];
        segmant(1);
        c++;
    }
    for (int i=0;i<n;i++) finalHeight[i] = min(finalHeight[i],mn(i+n));
}

Compilation message (stderr)

wall.cpp:54:83: error: declaration of 'finalHeight' as array of references
   54 | void buildWall(int n, int k, int op[], int left[], int right[],int height[], int& finalHeight[]) {
      |                                                                                   ^~~~~~~~~~~
wall.cpp: In function 'void buildWall(...)':
wall.cpp:59:12: error: 'op' was not declared in this scope
   59 |     while (op[c] == 1 && c < k) {
      |            ^~
wall.cpp:59:30: error: 'k' was not declared in this scope
   59 |     while (op[c] == 1 && c < k) {
      |                              ^
wall.cpp:60:15: error: 'height' was not declared in this scope
   60 |         num = height[c];L = left[c];R = right[c];
      |               ^~~~~~
wall.cpp:60:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   60 |         num = height[c];L = left[c];R = right[c];
      |                                   ^
wall.cpp:60:35: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   60 |         num = height[c];L = left[c];R = right[c];
      |                             ~~~~~~^
      |                                   |
      |                                   std::ios_base& (*)(std::ios_base&)
wall.cpp:60:48: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   60 |         num = height[c];L = left[c];R = right[c];
      |                                                ^
wall.cpp:60:48: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   60 |         num = height[c];L = left[c];R = right[c];
      |                                         ~~~~~~~^
      |                                                |
      |                                                std::ios_base& (*)(std::ios_base&)
wall.cpp:64:27: error: 'finalHeight' was not declared in this scope
   64 |     for (int i=0;i<n;i++) finalHeight[i] = mx(i+n);
      |                           ^~~~~~~~~~~
wall.cpp:67:12: error: 'op' was not declared in this scope
   67 |     while (op[c] == 2 && c < k) {
      |            ^~
wall.cpp:67:30: error: 'k' was not declared in this scope
   67 |     while (op[c] == 2 && c < k) {
      |                              ^
wall.cpp:68:15: error: 'height' was not declared in this scope
   68 |         num = height[c];L = left[c];R = right[c];
      |               ^~~~~~
wall.cpp:68:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   68 |         num = height[c];L = left[c];R = right[c];
      |                                   ^
wall.cpp:68:35: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   68 |         num = height[c];L = left[c];R = right[c];
      |                             ~~~~~~^
      |                                   |
      |                                   std::ios_base& (*)(std::ios_base&)
wall.cpp:68:48: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   68 |         num = height[c];L = left[c];R = right[c];
      |                                                ^
wall.cpp:68:48: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'int' [-fpermissive]
   68 |         num = height[c];L = left[c];R = right[c];
      |                                         ~~~~~~~^
      |                                                |
      |                                                std::ios_base& (*)(std::ios_base&)
wall.cpp:72:27: error: 'finalHeight' was not declared in this scope
   72 |     for (int i=0;i<n;i++) finalHeight[i] = min(finalHeight[i],mn(i+n));
      |                           ^~~~~~~~~~~