Submission #421308

#TimeUsernameProblemLanguageResultExecution timeMemory
421308JUANDI321Comparing 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; sumpf[1] = 200010; //cout<<sumpf[1]<<" "; //copyr[0] = r[0]; for(int i = 1; i<r.size(); i++) { sumpf[i+1]=sumpf[i]+r[i]; if(r[i]==0)sumpf[i+1]--; 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; } x++; y++; int dis = y-x+1; //cout<<dis<<endl; //cout<<sumpf[y]-sumpf[x-1]<<endl; if(sumpf[y]-sumpf[x-1] == dis)return 1; if(sumpf[y]-sumpf[x-1] == -1*dis)return -1; return 0; }

Compilation message (stderr)

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