제출 #123812

#제출 시각아이디문제언어결과실행 시간메모리
123812MAMBA로봇 (IOI13_robots)C++17
컴파일 에러
0 ms0 KiB
#incldue <bits/stdc++.h> #include "robots.h" using namespace std; #define rep(i , j , k) for (int i = j; i < (int)k; i++) typedef pair<int , int> pii; const int MAXN = 1e6 + 10; int a[MAXN], w[MAXN], s[MAXN], x[MAXN], y[MAXN], fA , fB, t; int arr[MAXN], rtp; inline void push(int v) { arr[++rtp] = v; int id = rtp; while (id > 1 && arr[id >> 1] < arr[id]) { swap(arr[id] , arr[id >> 1]); id >>= 1; } } inline void pop() { if (rtp == 1) return rtp = 0, void(); swap(arr[1] , arr[rtp--]); int id = 1; while (true) { if ((id << 1) > rtp) return; if ((id << 1) == rtp) { if (arr[id] < arr[id << 1]) swap(arr[id] , arr[id << 1]); return; } int me = id << 1; if (arr[me] < arr[me + 1]) me++; if (arr[id] < arr[me]) { swap(arr[id] , arr[me]); id = me; } else return; } } inline bool check(int mid) { rtp = 0; int ptr = 0; rep(i , 0 , fA) { while (ptr < t && w[a[ptr]] < x[i]) push(s[a[ptr++]]); rep(j , 0 , mid) { if (rtp) pop(); else break; } } while (ptr < t) push(s[a[ptr++]]); rep(i , 0 , fB) rep(j , 0 , mid) { if (rtp && arr[1] >= y[i]) return false; if (rtp) pop(); else break; } return !rtp; } bool cmp(int l , int r) { return pii(w[l] , s[l]) < pii(w[r] , s[r]); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { fA = A, fB = B,t = T; iota(a , a + T , 0); rep(i , 0 , T) w[i] = W[i], s[i] = S[i]; rep(i , 0 , A) x[i] = X[i]; rep(i , 0 , B) y[i] = Y[i]; sort(a , a + T, cmp); if (A) sort(x , x + A); if (B) sort(y , y + B, greater<int>()); long long lo = -1, hi = T + 1; while (lo != hi - 1) { int mid = lo + hi >> 1; if (check(mid)) hi = mid; else lo = mid; } if (hi == T + 1) hi = -1; return hi; }

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

robots.cpp:1:2: error: invalid preprocessing directive #incldue; did you mean #include?
 #incldue <bits/stdc++.h>
  ^~~~~~~
  include
robots.cpp:7:9: error: 'pair' does not name a type
 typedef pair<int , int> pii;
         ^~~~
robots.cpp: In function 'void push(int)':
robots.cpp:19:3: error: 'swap' was not declared in this scope
   swap(arr[id] , arr[id >> 1]);
   ^~~~
robots.cpp: In function 'void pop()':
robots.cpp:26:2: error: 'swap' was not declared in this scope
  swap(arr[1] , arr[rtp--]);
  ^~~~
robots.cpp: In function 'bool cmp(int, int)':
robots.cpp:70:34: error: 'pii' was not declared in this scope
 bool cmp(int l , int r) { return pii(w[l] , s[l]) < pii(w[r] , s[r]); }
                                  ^~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:76:2: error: 'iota' was not declared in this scope
  iota(a , a + T , 0);
  ^~~~
robots.cpp:76:2: note: suggested alternative: 'int'
  iota(a , a + T , 0);
  ^~~~
  int
robots.cpp:82:2: error: 'sort' was not declared in this scope
  sort(a , a + T, cmp);
  ^~~~
robots.cpp:82:2: note: suggested alternative: 'short'
  sort(a , a + T, cmp);
  ^~~~
  short
robots.cpp:85:25: error: 'greater' was not declared in this scope
  if (B) sort(y , y + B, greater<int>());
                         ^~~~~~~
robots.cpp:85:33: error: expected primary-expression before 'int'
  if (B) sort(y , y + B, greater<int>());
                                 ^~~
robots.cpp:89:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = lo + hi >> 1;
             ~~~^~~~