Submission #835575

#TimeUsernameProblemLanguageResultExecution timeMemory
835575rubdaryComparing Plants (IOI20_plants)C++14
5 / 100
65 ms8280 KiB
#include "plants.h" #include <iostream> using namespace std; int N; vector <int> sum; void init(int k, vector<int> r){ sum.push_back(0); for(int i = 0; i < r.size(); i++){ sum.push_back(sum.back()+r[i]); } return; } int lower(int x, int y){ int suma = sum[y] - sum[x]; int cant = y - x; if(suma == 0) return 1; if(suma == cant) return -1; suma = (sum.back() - sum[y]) + (sum[x]); cant = N - cant; if(suma == 0) return -1; if(suma == cant) return 1; return 0; } int higher(int x, int y){ int suma = sum[x] - sum[y]; int cant = x - y; if(suma == 0) return -1; if(suma == cant) return 1; suma = (sum.back() - sum[x]) + (sum[y]); cant = N - cant; if(suma == 0) return 1; if(suma == cant) return -1; return 0; } int compare_plants(int x, int y){ N = sum.size()-1; if(x < y) return lower(x, y); return higher(x, y); }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i = 0; i < r.size(); i++){
      |                 ~~^~~~~~~~~~
#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...