제출 #123771

#제출 시각아이디문제언어결과실행 시간메모리
123771MAMBA로봇 (IOI13_robots)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "robots.h"

using namespace std;

#define rep(i , j , k) for (int i = j; i < (int)k; i++)

const int MAXN = 1e6 + 10;

template <typename junk>
struct con {
  junk arr[MAXN];
  int ptr = 0;
  void pop_back() {
    ptr--;
  }
  void push_back(junk x) {
    arr[ptr] = x;
  }
  
};

int a[MAXN], w[MAXN];
priority_queue<int, con> st;

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
   
	iota(a , a + T , 0);

	rep(i , 0 , T) w[i]= W[i];

	sort(a , a + T, [](int l , int r) { return w[l] < w[r]; });

	sort(X , X + A);
	sort(Y , Y + B, greater<int>());

	int lo = -1, hi = T + 1;
	while (lo != hi - 1) {
		int mid = lo + hi >> 1;

		while (st.size()) st.pop();
		int ptr = 0;
		rep(i , 0 , A) {
			while (ptr < T && W[a[ptr]] < X[i]) 
				st.push(S[a[ptr++]]);
			rep(j , 0 , mid)
				if (st.size()) 
					st.pop();
		}
		while (ptr < T)
			st.push(S[a[ptr++]]);
		rep(i , 0 ,B)
			rep(j , 0 , mid)
				if (st.size() && st.top() < Y[i])
					st.pop();
		if (st.empty())
			hi = mid;
		else 
			lo = mid;
	}
	if (hi == T + 1) hi = -1;
	return hi;
}

컴파일 시 표준 에러 (stderr) 메시지

robots.cpp:24:24: error: type/value mismatch at argument 2 in template parameter list for 'template<class _Tp, class _Sequence, class _Compare> class std::priority_queue'
 priority_queue<int, con> st;
                        ^
robots.cpp:24:24: note:   expected a type, got 'con'
robots.cpp:24:24: error: template argument 3 is invalid
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:39:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = lo + hi >> 1;
             ~~~^~~~
robots.cpp:41:13: error: request for member 'size' in 'st', which is of non-class type 'int'
   while (st.size()) st.pop();
             ^~~~
robots.cpp:41:24: error: request for member 'pop' in 'st', which is of non-class type 'int'
   while (st.size()) st.pop();
                        ^~~
robots.cpp:45:8: error: request for member 'push' in 'st', which is of non-class type 'int'
     st.push(S[a[ptr++]]);
        ^~~~
robots.cpp:47:12: error: request for member 'size' in 'st', which is of non-class type 'int'
     if (st.size()) 
            ^~~~
robots.cpp:48:9: error: request for member 'pop' in 'st', which is of non-class type 'int'
      st.pop();
         ^~~
robots.cpp:51:7: error: request for member 'push' in 'st', which is of non-class type 'int'
    st.push(S[a[ptr++]]);
       ^~~~
robots.cpp:54:12: error: request for member 'size' in 'st', which is of non-class type 'int'
     if (st.size() && st.top() < Y[i])
            ^~~~
robots.cpp:54:25: error: request for member 'top' in 'st', which is of non-class type 'int'
     if (st.size() && st.top() < Y[i])
                         ^~~
robots.cpp:55:9: error: request for member 'pop' in 'st', which is of non-class type 'int'
      st.pop();
         ^~~
robots.cpp:56:10: error: request for member 'empty' in 'st', which is of non-class type 'int'
   if (st.empty())
          ^~~~~