Submission #1050475

#TimeUsernameProblemLanguageResultExecution timeMemory
1050475MercubytheFirstComparing Plants (IOI20_plants)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "plants.h" template<typename T, size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a); template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v); template<typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p); template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s); template<typename T, typename cmp> std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s); using namespace std; void init(int k, std::vector<int> r) { } int compare_plants(int x, int y) { int x = rand() % 2; return 2*x - 1; } template<typename T, size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a) { os << "["; for(size_t i = 0; i + 1 < N; ++i) { os << a[i] << ", "; } if(N > 0) os << a[N - 1]; os << "]"; return os; } template<typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) { os << "(" << p.first << ", " << p.second << ") "; return os; } template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) { os << '['; for(auto x : v) os << x << ", "; os << "] "; return os; } template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s) { os << "{"; for(auto x : s) os << x << ", "; os << "} "; return os; } // template<typename T, typename cmp> std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s) { os << "{"; for(auto x : s) os << x << ", "; os << "} "; return os; } /* 7 4 5 1 0 0 0 1 2 3 0 1 0 2 0 3 3 4 4 5 4 2 2 0 1 0 1 7 2 5 1 0 0 0 0 0 1 */

Compilation message (stderr)

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:20:6: error: declaration of 'int x' shadows a parameter
   20 |  int x = rand() % 2;
      |      ^
plants.cpp:19:24: note: 'int x' previously declared here
   19 | int compare_plants(int x, int y) {
      |                    ~~~~^