제출 #404703

#제출 시각아이디문제언어결과실행 시간메모리
404703ly20로봇 (IOI13_robots)C++17
컴파일 에러
0 ms0 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1123456; //x -> w //y -> s int x[MAXN], y[MAXN], w[MAXN], s[MAXN]; int va[MAXN], vb[MAXN]; int n, a, b; int marc[MAXN]; bool cmp1(int a, int b) { return w[a] < w[b]; } bool cmp2(int a, int b) { return s[a] < s[b]; } bool teste(int t) { priority_queue < pair <int, int> > s; int ts = 0; int cur = 0; for(int i = 0; i < a; i++) { while(w[va[cur]] < x[i]) { s.push(make_pair(s[va[cur]], va[cur])); } int cs = 0; while(cs < t) { if(s.empty()) break; pair <int, int> temp = s.top(); s.pop(); cs++; marc[temp.second] = 1; } } priority_queue <pair <int, int> > s2; for(int i = 0; i < n; i++) { if(marc[i] == 0) s2.push(make_pair(-s[i], i)); } for(int i = b - 1; i >= 0; i--) { int cs = 0; while(cs < t) { if(s2.empty()) break; pair <int, int> temp = s.top(); if(-temp.first >= y[i]) break; s.pop(); cs++; } } return ts == n; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { n = T; a = A; b = B; for(int i = 0; i < T; i++) { va[i] = i; vb[i] = i; w[i] = W[i]; s[i] = S[i]; } sort(va, va + n, cmp1); sort(vb, vb + n, cmp2); for(int i = 0; i < a; i++) x[i] = X[i]; for(int i = 0; i < b; i++) y[i] = Y[i]; sort(x, x + a); sort(y, y + b); int ini = 1, fim = MAXN; while(ini < fim) { for(int i = 0; i < t; i++) marc[i] = 0; int m = (ini + fim) / 2; if(teste(m)) { fim = m; } else ini = m + 1; } if(ini == MAXN) ini = -1; return ini; }

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

robots.cpp: In function 'bool teste(int)':
robots.cpp:25:31: error: no match for 'operator[]' (operand types are 'std::priority_queue<std::pair<int, int> >' and 'int')
   25 |             s.push(make_pair(s[va[cur]], va[cur]));
      |                               ^
robots.cpp:38:46: error: no match for 'operator[]' (operand types are 'std::priority_queue<std::pair<int, int> >' and 'int')
   38 |         if(marc[i] == 0) s2.push(make_pair(-s[i], i));
      |                                              ^
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:67:28: error: 't' was not declared in this scope
   67 |         for(int i = 0; i < t; i++) marc[i] = 0;
      |                            ^