Submission #962946

#TimeUsernameProblemLanguageResultExecution timeMemory
962946serkanrashidRobots (IOI13_robots)C++14
Compilation error
0 ms0 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; struct toy { int w,s; toy(){}; toy(int wi, int si) { w = wi; s = si; } }; int t; toy a[1e6]; int a,b,x[5e4],y[5e4]; bool cmp2(toy p1, toy p2) { if(p1.s==p2.s) return p1.w>p2.w; return p1.s<p2.s; } bool check(int z) { int p = 0; for(int i = 0; i < a; i++) { int br = 0; while(br<z&&p<t&&a[p].w<=x[i]) { br++; p++; } } vector<toy>pom; for(int i = p; i < t; i++) pom.push_back(a[i]); sort(pom.begin(),pom.end(),cmp2); p = 0; for(int i = 0; i < a; i++) { int br = 0; while(br<z&&p<pom.size()&&a[p].s<=y[i]) { br++; p++; } } return p>=pom.size(); } bool cmp1(toy p1, toy p2) { if(p1.w==p2.w) return p1.s>p2.s; return p1.w<p2.w; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a = A; b = B; for(int i = 0; i < A; i++) x[i] = X[i]-1; for(int i = 0; i < B; i++) y[i] = Y[i]-1; t = T; for(int i = 0; i < T; i++) { a[i].w = W[i]; a[i].s = S[i]; } if(a) sort(x,x+a); if(b) sort(y,y+b); for(int i = 0; i < T; i++) if((!a||w[i]>x[a-1])&&(!b||s[i]>y[b-1])) return -1; sort(a,a+t,cmp1); int l = 1, r = t; int mid; while(l<=r) { mid = (l+r)/2; if(check(mid)) r = mid-1; else l = mid+1; } return l; }

Compilation message (stderr)

robots.cpp:18:7: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   18 | toy a[1e6];
      |       ^~~
robots.cpp:18:7: error: could not convert '1.0e+6' from 'double' to 'long unsigned int'
robots.cpp:18:7: error: size of array 'a' has non-integral type 'double'
robots.cpp:20:5: error: conflicting declaration 'int a'
   20 | int a,b,x[5e4],y[5e4];
      |     ^
robots.cpp:18:5: note: previous declaration as 'toy a [1]'
   18 | toy a[1e6];
      |     ^
robots.cpp:20:11: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   20 | int a,b,x[5e4],y[5e4];
      |           ^~~
robots.cpp:20:11: error: could not convert '5.0e+4' from 'double' to 'long unsigned int'
robots.cpp:20:11: error: size of array 'x' has non-integral type 'double'
robots.cpp:20:18: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   20 | int a,b,x[5e4],y[5e4];
      |                  ^~~
robots.cpp:20:18: error: could not convert '5.0e+4' from 'double' to 'long unsigned int'
robots.cpp:20:18: error: size of array 'y' has non-integral type 'double'
robots.cpp: In function 'bool check(int)':
robots.cpp:31:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   31 |     for(int i = 0; i < a; i++)
      |                    ~~^~~
robots.cpp:44:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   44 |     for(int i = 0; i < a; i++)
      |                    ~~^~~
robots.cpp:47:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<toy>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         while(br<z&&p<pom.size()&&a[p].s<=y[i])
      |                     ~^~~~~~~~~~~
robots.cpp:53:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<toy>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     return p>=pom.size();
      |            ~^~~~~~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:64:7: error: incompatible types in assignment of 'int' to 'toy [1]'
   64 |     a = A;
      |     ~~^~~
robots.cpp:74:19: error: invalid operands of types 'int [1]' and 'toy [1]' to binary 'operator+'
   74 |     if(a) sort(x,x+a);
      |                  ~^~
      |                  | |
      |                  | toy [1]
      |                  int [1]
robots.cpp:76:40: error: 'w' was not declared in this scope
   76 |     for(int i = 0; i < T; i++) if((!a||w[i]>x[a-1])&&(!b||s[i]>y[b-1])) return -1;
      |                                        ^
robots.cpp:76:46: error: invalid types 'int [1][toy*]' for array subscript
   76 |     for(int i = 0; i < T; i++) if((!a||w[i]>x[a-1])&&(!b||s[i]>y[b-1])) return -1;
      |                                              ^
robots.cpp:76:59: error: 's' was not declared in this scope
   76 |     for(int i = 0; i < T; i++) if((!a||w[i]>x[a-1])&&(!b||s[i]>y[b-1])) return -1;
      |                                                           ^