Submission #309687

#TimeUsernameProblemLanguageResultExecution timeMemory
309687amunduzbaevRobots (IOI13_robots)C++14
14 / 100
188 ms9080 KiB
#include "robots.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+5;
const int N1=5e4+5;
int t,a,b,a1[N1],b1[N1],w[N],s[N];

int putaway(int A, int B, int T, int A1[], int B1[], int W[], int S[]) {
    t=T,a=A,b=B;
    for(int i=0;i<t;i++){
        w[i]=W[i];
        s[i]=S[i];
    }
    for(int i=0;i<a;i++) a1[i]=A1[i];
    for(int i=0;i<b;i++) b1[i]=B1[i];
    sort(a1,a1+a);
    sort(b1,b1+b);
    if(t==2){
        for(int i=0;i<t;i++){
            if(a&&b){
                if(w[i]>=a1[a-1]&&s[i]>=b1[b-1]) return -1;
            }else if(a){
                if(w[i]>=a1[a-1]) return -1;
            }else{
                if(s[i]>=b1[b-1]) return -1;
            }
        }

        if(a>0&&b>0){
            return (a1[0]>w[0]&&b1[0]>s[1]||a1[0]>w[1]&&b1[0]>s[0]) ? 1 : 2 ;
        }
        if(a>0){
            return (a1[0]>w[0]&&a1[1]>w[1]||a1[1]>w[0]&&a1[0]>w[1]) ? 1 : 2 ;
        }
        if(b>0){
            return (b1[0]>s[0]&&b1[1]>s[1]||b1[1]>s[0]&&b1[0]>s[1]) ? 1 : 2 ;
        }
    }

}

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:31:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   31 |             return (a1[0]>w[0]&&b1[0]>s[1]||a1[0]>w[1]&&b1[0]>s[0]) ? 1 : 2 ;
      |                     ~~~~~~~~~~^~~~~~~~~~~~
robots.cpp:34:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   34 |             return (a1[0]>w[0]&&a1[1]>w[1]||a1[1]>w[0]&&a1[0]>w[1]) ? 1 : 2 ;
      |                     ~~~~~~~~~~^~~~~~~~~~~~
robots.cpp:37:31: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   37 |             return (b1[0]>s[0]&&b1[1]>s[1]||b1[1]>s[0]&&b1[0]>s[1]) ? 1 : 2 ;
      |                     ~~~~~~~~~~^~~~~~~~~~~~
robots.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
   41 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...