Submission #421313

#TimeUsernameProblemLanguageResultExecution timeMemory
421313JUANDI321Comparing Plants (IOI20_plants)C++17
0 / 100
1 ms300 KiB
#include "plants.h" #include <vector> #include <iostream> using namespace std; int sumpf[200010], copyr[20010]; int n; void init(int k, vector<int> r) { n = r.size(); sumpf[0] = 200010; //cout<<sumpf[1]<<" "; copyr[0] = r[0]; for(int i = 1; i < r.size(); i++) { sumpf[i] = sumpf[i-1] + r[i-1]; if(r[i-1] == 0) sumpf[i]--; copyr[i] = r[i]; // cout<<sumpf[i+1]<<" "; } //cout<<endl; return; } int compare_plants(int x, int y) { if(x == 0 && y == n-1) { if(copyr[n-1] == 1) return 1; return -1; } int dis = y-x+1; //cout<<dis<<endl; //cout<<sumpf[y]-sumpf[x-1]<<endl; int sum = sumpf[y] - sumpf[x-1]; if(x == 0)sum = sumpf[y]; if(sum == dis) return 1; if(sum == -1 * dis) return -1; int sb = x; x = y; y = sb; dis = y-x+1; //cout<<dis<<endl; //cout<<sumpf[y]-sumpf[x-1]<<endl; sum = sumpf[y] - sumpf[x-1]; if(x == 0)sum = sumpf[y]; if(sum == dis) return 1; if(sum == -1 * dis) return -1; return 0; }

Compilation message (stderr)

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