Submission #431496

#TimeUsernameProblemLanguageResultExecution timeMemory
431496HazemComparing Plants (IOI20_plants)C++14
0 / 100
1 ms248 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+1); else return (pr.back()-pr[x-1]+(y?pr[y-1]:0))==(pr.size()-x+y); } int compare_plants(int x, int y) { if(check(x,y)) return -1; if(check(y,x)) 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...