Help with submitting code

I have been trying to submit my code for the USACO Silver 2019 January contest problem “Grass Planting” Problem

When trying to submit, I get this error:

I have looked through my code several times, but it does not seem to me that I did anything wrong. Here is my code:

#include <bits/stdc++.h> // see C++ Tips & Tricks
using namespace std;

using ll = long long;

using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

void setIO(string name = "") { // name is nonempty for USACO file I/O
	cin.tie(0)->sync_with_stdio(0); // see Fast Input & Output
	if (sz(name)) {
		freopen((name+".in").c_str(), "r", stdin); // see Input & Output
		freopen((name+".out").c_str(), "w", stdout);
	}
}

int main() {
	setIO("planting");
	cin.tie(0)->sync_with_stdio(0);
    int n;
    cin >> n;
    int a, b;
    int c[100000];
    for(int i = 0; i < n-1; i++){
        cin >> a >> b;
        c[a]++;
        c[b]++;
    }
    int maxnum = 0;
    for(int i = 0; i < n; i++){
        if(c[i] > maxnum){
            maxnum = c[i];
        }
    }
    cout << maxnum + 1 << endl;
}

Is there anything I have done wrong?

1 Like

You might need to initialize your array to all zeroes (or declare the array globally)? Not sure, haven’t tested

1 Like

Ok, will do later tomorrow.