Submission #434588

#TimeUsernameProblemLanguageResultExecution timeMemory
434588pere_gilComparing Plants (IOI20_plants)C++17
5 / 100
120 ms6104 KiB
#include "plants.h" #include "bits/stdc++.h" using namespace std; vector<int> v; vector<int> acc; int tam; void init(int k, std::vector<int> r) { v=r; tam=k; acc.push_back(v[0]); for(int i=1;i<v.size();i++) acc.push_back(acc[i-1]+v[i]); return; } bool op1(int l, int r){ int aux; if(l<r){ aux=acc[r-1]; aux-=(l==0) ? 0 : acc[l-1]; return aux==(r-l); } aux=acc.back()-acc[l-1]; aux+=(r==0) ? 0 : acc[r-1]; return aux==(acc.size()-l+r); } bool op2(int l, int r){ int aux; if(l<r){ aux=acc[r-1]; aux-=(l==0) ? 0 : acc[l-1]; return !aux; } aux=acc.back()-acc[l-1]; aux+=(r==0) ? 0 : acc[r-1]; return !aux; } int compare_plants(int x, int y) { if(op1(x,y) || op2(y,x)) return -1; if(op1(y,x) || op2(x,y)) return 1; return 0; return 0; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=1;i<v.size();i++)
      |              ~^~~~~~~~~
plants.cpp: In function 'bool op1(int, int)':
plants.cpp:30:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  return aux==(acc.size()-l+r);
      |         ~~~^~~~~~~~~~~~~~~~~~
#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...