답안 #723394

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723394 2023-04-13T16:59:30 Z Quentolosse Measures (CEOI22_measures) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#define int long long

using namespace std;

const int inf = 1e9;

struct node
{
    int maxi = -inf, mini = inf, reponse = -inf, decalage = 0;
};

vector<node> segtree;
int n, m, d;

node merge (node a, node b)
{
    node c;
    c.maxi = max(a.max + a.decalage, b.max + b.decalage);
    c.mini = min(a.min + a.decalage, b.min + b.decalage);
    c.reponse = max(b.max - a.min, max(a.reponse, b.reponse));
    return c;
}

void update (int i, node a)
{
    segtree[i] = a;
    if (i == 1)
    {
        return;
    }
    if (i % 2)
    {
        update((i - 1) / 2, merge(segtree[i - 1], segtree[i]));
    }
    else
    {
        update(i / 2, merge(segtree[i], segtree[i + 1]));
    }
}

void decalage (int i, int L, int l, int r, int R)
{
    if (L == l && r == R)
    {
        segtree[i].decalage = 
    }
    decalage(i * 2, )
}

signed main() {

    ios::sync_with_stdio(false), cin.tie(0);

    cin >> n >> m >> d;

    segtree.resize(2 * (n + m));
    vector<int> debut (n);

    for (int i = 0; i < n; i++)
    {
        cin >> debut[i];
    }

    vector<int> requetes (m);

    for (int i = 0; i < m; i++)
    {
        cin >> requetes[i];
    }
    
    vector<pair<int, int>> points (n + m);

    for (int i = 0; i < n; i++)
    {
        points[i].first = debut[i];
        points[i].second = i;
    }

    for (int i = 0; i < m; i ++)
    {
        points[n + i].first = requetes[i];
        points[n + i].second = n + i;
    }

    sort(points.begin(), points.end());

    vector<int> posRequete (m);

    for (int i = 0; i < n + m; i++)
    {
        if (points[i].second < n)
        {
            segtree[n + m + i + 1].max = points[i].first;
            segtree[n + m + i + 1].min = points[i].first;
        } 
        else
        {
            posRequete[points[i].first] = i;
        }
    }

    for (int i = 0; i < m; i++)
    {
        int pos = posRequete[i];
        node a;
        a.max = points[pos];
        a.min = points[pos];

        update(n + m + i + pos, a);
        
        decalage(1, 0, pos, n + m, n + m)

        cout << segtree[1].reponse << ' ';
    }

}

Compilation message

Main.cpp: In function 'node merge(node, node)':
Main.cpp:20:20: error: 'struct node' has no member named 'max'; did you mean 'maxi'?
   20 |     c.maxi = max(a.max + a.decalage, b.max + b.decalage);
      |                    ^~~
      |                    maxi
Main.cpp:20:40: error: 'struct node' has no member named 'max'; did you mean 'maxi'?
   20 |     c.maxi = max(a.max + a.decalage, b.max + b.decalage);
      |                                        ^~~
      |                                        maxi
Main.cpp:21:20: error: 'struct node' has no member named 'min'; did you mean 'mini'?
   21 |     c.mini = min(a.min + a.decalage, b.min + b.decalage);
      |                    ^~~
      |                    mini
Main.cpp:21:40: error: 'struct node' has no member named 'min'; did you mean 'mini'?
   21 |     c.mini = min(a.min + a.decalage, b.min + b.decalage);
      |                                        ^~~
      |                                        mini
Main.cpp:22:23: error: 'struct node' has no member named 'max'; did you mean 'maxi'?
   22 |     c.reponse = max(b.max - a.min, max(a.reponse, b.reponse));
      |                       ^~~
      |                       maxi
Main.cpp:22:31: error: 'struct node' has no member named 'min'; did you mean 'mini'?
   22 |     c.reponse = max(b.max - a.min, max(a.reponse, b.reponse));
      |                               ^~~
      |                               mini
Main.cpp: In function 'void decalage(long long int, long long int, long long int, long long int, long long int)':
Main.cpp:48:5: error: expected primary-expression before '}' token
   48 |     }
      |     ^
Main.cpp:49:21: error: expected primary-expression before ')' token
   49 |     decalage(i * 2, )
      |                     ^
Main.cpp: In function 'int main()':
Main.cpp:95:36: error: '__gnu_cxx::__alloc_traits<std::allocator<node>, node>::value_type' {aka 'struct node'} has no member named 'max'; did you mean 'maxi'?
   95 |             segtree[n + m + i + 1].max = points[i].first;
      |                                    ^~~
      |                                    maxi
Main.cpp:96:36: error: '__gnu_cxx::__alloc_traits<std::allocator<node>, node>::value_type' {aka 'struct node'} has no member named 'min'; did you mean 'mini'?
   96 |             segtree[n + m + i + 1].min = points[i].first;
      |                                    ^~~
      |                                    mini
Main.cpp:108:11: error: 'struct node' has no member named 'max'; did you mean 'maxi'?
  108 |         a.max = points[pos];
      |           ^~~
      |           maxi
Main.cpp:109:11: error: 'struct node' has no member named 'min'; did you mean 'mini'?
  109 |         a.min = points[pos];
      |           ^~~
      |           mini
Main.cpp:113:42: error: expected ';' before 'cout'
  113 |         decalage(1, 0, pos, n + m, n + m)
      |                                          ^
      |                                          ;
  114 | 
  115 |         cout << segtree[1].reponse << ' ';
      |         ~~~~