Need help understanding USACO Bronze Livestock Lineup 2019

I am a beginner, just starting to learn programming for USACO. I’m trying to solve this problem: USACO

and I found this solution:
Solution - Livestock Lineup (USACO Bronze 2019 December) · USACO Guide

but need help understanding a part of the solution given for Livestock Lineup problem. They are using a pushback method for an array


I can’t find any information on what adj[c1] means. Based on the information I found, the pushback method is used as adj.push_back(). Can someone please explain what the [c1] is for?

Also, when I copy the code and run it in the I get an error for these lines
freopen(“”, “r”, stdin);
freopen(“lineup.out”, “w”, stdout);

Why does it give me an error for these lines? Any help would be greatly appreciated.

Thank you!

adj is an array of vectors. adj[c1] refers the c1'th element of that array, which is a vector. adj[c1].push_back(c2) pushes back c2 to that vector. This representation is quite common; you can see it used here as well. Also see CPH for more info.

These lines are for file input/output. You need to comment them out to use standard input/output.

By the way, you should surround all code with code blocks, like so: