답안 #856171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856171 2023-10-02T18:39:58 Z Benmath popa (BOI18_popa) C++14
컴파일 오류
0 ms 0 KB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
#include<popa.h>
#include <bits/stdc++.h>

using namespace std;
using pii = pair<int,pair<int,int>>;
int solver(int prvi, int drugi, int lijevo[], int desno[]){
    for(int i = prvi; i <= drugi; i++){
        if(lijevo[i] <= prvi and drugi <= desno[i]){
            return i;
        }
    }
}
int solve(int N, int* Left, int* Right){
    int n = N;
    int lijevo[n];
    int desno[n];
    for(int i = 0; i < n; i++){
        Left[i] = -1;
        Right[i] = -1;
       lijevo[i] = i;
       int l = 0;
       int r = i - 1;
       while(l <= r){
           int mid = (l + r)/2;
           if(query(mid, i, i, i) == 1){
               lijevo[i] = min(lijevo[i] , mid);
               r = mid - 1;
           }else{
               l = mid + 1;
           }
       }
       l = i + 1;
       desno[i] = i;
       r = n - 1;
       while(l <= r){
           int mid = (l + r)/2;
           if(query(i,mid, i, i) == 1){
               desno[i] = max(desno[i], mid);
               l = mid + 1;
           }else{
               r = mid - 1;
           }
       }
    }
    int root = solver(0,n - 1, lijevo, desno);
    int interval1 = 0;
    queue<int,pair<int,int>>q;
    q.push({root,{0, n - 1}});
    while(!q.empty()){
        pii a = q.front();
        q.pop();
        int trenutni = a.first;
        int prvi = a.second.first;
        int drugi = a.second.second;
        if(prvi < trenutni){
            int x = solver(prvi, trenutni - 1, lijevo, desno);
            Left[trenutni] = x;
            q.push({x,{prvi,trenutni - 1}});
        }
        if(trenutni < drugi){
            int x = solver(drugi, trenutni - 1, lijevo,desno);
            Right[trenutni] = x;
            q.push({x,{trenutni + 1, drugi}});
        }
    }
    return root;
    
}

Compilation message

In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from popa.cpp:9:
/usr/include/c++/10/bits/stl_queue.h: In instantiation of 'class std::queue<int, std::pair<int, int> >':
popa.cpp:54:29:   required from here
/usr/include/c++/10/bits/stl_queue.h:138:47: error: no type named 'value_type' in 'struct std::pair<int, int>'
  138 |       typedef typename _Sequence::value_type  value_type;
      |                                               ^~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:139:46: error: no type named 'reference' in 'struct std::pair<int, int>'
  139 |       typedef typename _Sequence::reference  reference;
      |                                              ^~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:140:51: error: no type named 'const_reference' in 'struct std::pair<int, int>'
  140 |       typedef typename _Sequence::const_reference const_reference;
      |                                                   ^~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_queue.h:141:46: error: no type named 'size_type' in 'struct std::pair<int, int>'
  141 |       typedef typename _Sequence::size_type  size_type;
      |                                              ^~~~~~~~~
popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:55:7: error: 'class std::queue<int, std::pair<int, int> >' has no member named 'push'
   55 |     q.push({root,{0, n - 1}});
      |       ^~~~
popa.cpp:57:19: error: 'class std::queue<int, std::pair<int, int> >' has no member named 'front'
   57 |         pii a = q.front();
      |                   ^~~~~
popa.cpp:65:15: error: 'class std::queue<int, std::pair<int, int> >' has no member named 'push'
   65 |             q.push({x,{prvi,trenutni - 1}});
      |               ^~~~
popa.cpp:70:15: error: 'class std::queue<int, std::pair<int, int> >' has no member named 'push'
   70 |             q.push({x,{trenutni + 1, drugi}});
      |               ^~~~
popa.cpp:53:9: warning: unused variable 'interval1' [-Wunused-variable]
   53 |     int interval1 = 0;
      |         ^~~~~~~~~
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from popa.cpp:9:
/usr/include/c++/10/bits/stl_queue.h: In instantiation of 'bool std::queue<_Tp, _Sequence>::empty() const [with _Tp = int; _Sequence = std::pair<int, int>]':
popa.cpp:56:20:   required from here
/usr/include/c++/10/bits/stl_queue.h:204:18: error: 'const struct std::pair<int, int>' has no member named 'empty'
  204 |       { return c.empty(); }
      |                ~~^~~~~
/usr/include/c++/10/bits/stl_queue.h: In instantiation of 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = int; _Sequence = std::pair<int, int>]':
popa.cpp:58:15:   required from here
/usr/include/c++/10/bits/stl_queue.h:301:4: error: 'struct std::pair<int, int>' has no member named 'pop_front'
  301 |  c.pop_front();
      |  ~~^~~~~~~~~
popa.cpp: In function 'int solver(int, int, int*, int*)':
popa.cpp:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^