Submission #309991

#TimeUsernameProblemLanguageResultExecution timeMemory
309991juggernautRobots (IOI13_robots)C++14
Compilation error
0 ms0 KiB
#include"robots.h" #include<bits/stdc++.h> #define fr first #define sc second //#include"grader.c" using namespace std; int a,b,t,x[50005],y[50005]; pair<int,int>toy[1000005]; inline bool check(int m){ priority_queue<int>q; for(int i=0,tt=0;i<=a;i++){ for(;tt<t&&toy[tt].fr<x[i];tt++)q.push(toy[tt].sc); if(i!=a)for(int j=0;j<m&&(!q.empty());j++)q.pop(); } for(int i=b-1;i>=0&&(q.empty()||q.top()<y[i]);i--) for(int j=0;j<m&&(!q.empty());j++)q.pop(); return q.empty(); } int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){ a=A,b=B,t=T; x[a]=2e9+1; memcpy(x,X,X+A); memcpy(y,Y,Y+B); for(int i=0;i<t;i++)toy[i]={W[i],S[i]}; sort(x,x+a); sort(y,y+b); sort(toy,toy+t); int l=1,r=t; while(l<r){ int mid=(l+r)>>1; if(check(mid))r=mid; else l=mid+1; } if(!check(l))return -1; return l; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:22:18: error: invalid conversion from 'int*' to 'size_t' {aka 'long unsigned int'} [-fpermissive]
   22 |      memcpy(x,X,X+A);
      |                 ~^~
      |                  |
      |                  int*
In file included from /usr/include/features.h:367,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/c++config.h:524,
                 from /usr/include/c++/9/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from robots.cpp:2:
/usr/include/x86_64-linux-gnu/bits/string3.h:50:1: note:   initializing argument 3 of 'void* memcpy(void*, const void*, size_t)'
   50 | __NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
      | ^~~~~
robots.cpp:23:15: error: invalid conversion from 'int*' to 'size_t' {aka 'long unsigned int'} [-fpermissive]
   23 |   memcpy(y,Y,Y+B);
      |              ~^~
      |               |
      |               int*
In file included from /usr/include/features.h:367,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/c++config.h:524,
                 from /usr/include/c++/9/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from robots.cpp:2:
/usr/include/x86_64-linux-gnu/bits/string3.h:50:1: note:   initializing argument 3 of 'void* memcpy(void*, const void*, size_t)'
   50 | __NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
      | ^~~~~