Submission #431515

#TimeUsernameProblemLanguageResultExecution timeMemory
431515HazemComparing Plants (IOI20_plants)C++14
5 / 100
111 ms5736 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; int k; vector<int>a,pr; void init(int K, std::vector<int> r) { k = k;a = pr = r; for(int i=1;i<a.size();i++) pr[i] += pr[i-1]; return; } bool check(int x,int y){ if(y>x) return (pr[y-1]-(x?pr[x-1]:0))==(y-x); else return (pr.back()-pr[x-1]+(y?pr[y-1]:0))==(pr.size()-x+y); } bool check1(int x,int y){ if(y>x) return (pr[y-1]-(x?pr[x-1]:0))==0; else return (pr.back()-pr[x-1]+(y?pr[y-1]:0))==0; } int compare_plants(int x, int y) { if(check(x,y)||check1(y,x)) return -1; if(check(y,x)||check1(x,y)) return 1; return 0; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i=1;i<a.size();i++)
      |              ~^~~~~~~~~
plants.cpp: In function 'bool check(int, int)':
plants.cpp:23:43: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   return (pr.back()-pr[x-1]+(y?pr[y-1]:0))==(pr.size()-x+y);
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...