제출 #108896

#제출 시각아이디문제언어결과실행 시간메모리
108896DodgeBallMan로봇 (IOI13_robots)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "robots.h" #define pii pair<int, int> #define x first #define y second using namespace std; vector<pii> all; int a, b, t, x[50010], y[50010]; bool check( int mid, int &w, int &s ) { priority_queue<pii> q; vector<bool> chk( t ); int j = 0; for( int i = 0 ; i < a ; i++ ) { int now = 0; while( j < t && all[j].x < x[i] ) q.emplace( pii( all[j].y, j ) ), j++; while( !q.empty() && now < mid ) chk[q.top().y] = 1, q.pop(), now++; } for( ; j < t ; j++ ) q.emplace( pii( all[j].y, j ) ); for( int i = b - 1 ; i >= 0 ; i-- ) { int now = 0; while( now < mid && !q.empty() ) { pii temp = q.top(); q.pop(); if( temp.x < y[i] ) now++, chk[temp.y] = 1; } } for( int i = 0 ; i < t ; i++ ) if( !chk[i] ) return false; return true; } int putaway( int A, int B, int T, int X[], int Y[], int w[], int s[] ) { a = A, b = B, t = T; for( int i = 0 ; i < a ; i++ ) x[i] = X[i]; for( int i = 0 ; i < b ; i++ ) y[i] = Y[i]; for( int i = 0 ; i < t ; i++ ) all.emplace_back( pii( w[i], s[i] ) ); sort( all.begin(), all.end() ), sort( x, x + a ), sort( y, y + b ); int l = 0, r = t; while( l < r ) { int mid = ( l + r + 1 ) >> 1; if( check( mid, w, s ) ) r = mid; else l = mid + 1; } if( !check( l, w, s ) ) return -1; else return l; }

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

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:42:30: error: invalid conversion from 'int*' to 'int' [-fpermissive]
         if( check( mid, w, s ) ) r = mid;
                              ^
robots.cpp:12:6: note:   initializing argument 2 of 'bool check(int, int&, int&)'
 bool check( int mid, int &w, int &s ) {
      ^~~~~
robots.cpp:42:30: error: cannot bind rvalue '(int)w' to 'int&'
         if( check( mid, w, s ) ) r = mid;
                              ^
robots.cpp:45:25: error: invalid conversion from 'int*' to 'int' [-fpermissive]
     if( !check( l, w, s ) ) return -1;
                         ^
robots.cpp:12:6: note:   initializing argument 2 of 'bool check(int, int&, int&)'
 bool check( int mid, int &w, int &s ) {
      ^~~~~
robots.cpp:45:25: error: cannot bind rvalue '(int)w' to 'int&'
     if( !check( l, w, s ) ) return -1;
                         ^
robots.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^