Submission #108891

#TimeUsernameProblemLanguageResultExecution timeMemory
108891DodgeBallManRobots (IOI13_robots)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "robots.h" #define pii pair<int, int> #define x first #define y second using namespace std; const int N = 1e6 + 10; vector<pii> all; int chk[N], a, b, t, x[50010], y[50010], w[N], s[N]; bool check( int mid ) { priority_queue<pii> q; memset( chk, 0, sizeof chk ); int j = 0, cc = 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++ ) w[i] = W[i], s[i] = S[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 ) ) r = mid; else l = mid + 1; } if( !check( l, a, b, t, x, y, w, s ) ) return -1; else return l; } // int main() // { // int n = 500, m = 100; // int a, b, t, x[n], y[n], w[m], s[m]; // scanf("%d %d %d",&a,&b,&t); // for( int i = 0 ; i < a ; i++ ) scanf("%d",&x[i]); // for( int i = 0 ; i < b ; i++ ) scanf("%d",&y[i]); // for( int i = 0 ; i < t ; i++ ) scanf("%d",&w[i]); // for( int i = 0 ; i < t ; i++ ) scanf("%d",&s[i]); // cout << putaway( a, b, t, x, y, w, s ); // }

Compilation message (stderr)

robots.cpp: In function 'bool check(int)':
robots.cpp:16:16: warning: unused variable 'cc' [-Wunused-variable]
     int j = 0, cc = 0;
                ^~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:47:40: error: too many arguments to function 'bool check(int)'
     if( !check( l, a, b, t, x, y, w, s ) ) return -1;
                                        ^
robots.cpp:13:6: note: declared here
 bool check( int mid ) {
      ^~~~~