답안 #284132

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284132 2020-08-26T22:09:34 Z Ozy 벽 (IOI14_wall) C++17
컴파일 오류
0 ms 0 KB
#include "wall.h"
#include <bits/stdc++.h>

#define lli long long int
#define rep(i,a,b) for (lli i = (a); i <= (b); i++)
#define MIN -100001

struct x{
    lli pos;
    lli tipo;
    lli val;

    bool operator < (const x &a)
    const {
        return pos < a.pos;
    }
};

set<lli> set1,set2;
vector<x> sum,res;
lli cant1[100002],cant2[100002];
lli cont1,cont2,a,b;

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){

    rep (i,0,k-1) {
        if (op[i] == q) {
            //agrega
            sum.push_back({left[i],1,height[i]});
            sum.push_back({right[i]+1,0,height[i]});
        }
        else {
            //quita
            res.push_back({left[i],1,height[i]});
            res.push_back({right[i]+1,0,height[i]});
        }
    }

    cont1 = 0;
    cont2 = 0;
    rep(i,0,n-1) {

        while (sum[cont1].pos == i) {
            if (sum[cont1].tipo == 1) {

                cant1[sum[cont1].val] ++;
                set1.insert(-(sum[cont1].val));

            }
            else {

                cant1[sum[val]]--;
                if (cant1[sum[cont1].val] == 0) set1.erase(-(sum[cont1].val));

            }

            cont1++;
        }


        while (res[cont2].pos == i) {
            if (res[cont2].tipo == 1) {

                cant2[res[cont2].val] ++;
                set2.insert(-(res[cont2].val));

            }
            else {

                cant2[res[val]]--;
                if (cant2[res[cont2].val] == 0) set1.erase(-(res[cont2].val));

            }

            cont1++;
        }

        a = abs(set1.lower_bound(MIN));
        b = abs(set2.lower_bound(MIN));

        finalHeight[i] = min(a,b);

    }

    return;
}

Compilation message

wall.cpp:19:1: error: 'set' does not name a type; did you mean 'setns'?
   19 | set<lli> set1,set2;
      | ^~~
      | setns
wall.cpp:20:1: error: 'vector' does not name a type
   20 | vector<x> sum,res;
      | ^~~~~~
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:27:22: error: 'q' was not declared in this scope
   27 |         if (op[i] == q) {
      |                      ^
wall.cpp:29:13: error: 'sum' was not declared in this scope
   29 |             sum.push_back({left[i],1,height[i]});
      |             ^~~
wall.cpp:34:13: error: 'res' was not declared in this scope; did you mean 'rep'?
   34 |             res.push_back({left[i],1,height[i]});
      |             ^~~
      |             rep
wall.cpp:43:16: error: 'sum' was not declared in this scope
   43 |         while (sum[cont1].pos == i) {
      |                ^~~
wall.cpp:47:17: error: 'set1' was not declared in this scope
   47 |                 set1.insert(-(sum[cont1].val));
      |                 ^~~~
wall.cpp:52:27: error: 'val' was not declared in this scope
   52 |                 cant1[sum[val]]--;
      |                           ^~~
wall.cpp:53:49: error: 'set1' was not declared in this scope
   53 |                 if (cant1[sum[cont1].val] == 0) set1.erase(-(sum[cont1].val));
      |                                                 ^~~~
wall.cpp:61:16: error: 'res' was not declared in this scope; did you mean 'rep'?
   61 |         while (res[cont2].pos == i) {
      |                ^~~
      |                rep
wall.cpp:65:17: error: 'set2' was not declared in this scope
   65 |                 set2.insert(-(res[cont2].val));
      |                 ^~~~
wall.cpp:70:27: error: 'val' was not declared in this scope
   70 |                 cant2[res[val]]--;
      |                           ^~~
wall.cpp:71:49: error: 'set1' was not declared in this scope
   71 |                 if (cant2[res[cont2].val] == 0) set1.erase(-(res[cont2].val));
      |                                                 ^~~~
wall.cpp:78:17: error: 'set1' was not declared in this scope
   78 |         a = abs(set1.lower_bound(MIN));
      |                 ^~~~
wall.cpp:79:17: error: 'set2' was not declared in this scope
   79 |         b = abs(set2.lower_bound(MIN));
      |                 ^~~~
wall.cpp:81:26: error: 'min' was not declared in this scope; did you mean 'std::min'?
   81 |         finalHeight[i] = min(a,b);
      |                          ^~~
      |                          std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~