This is no correct C code and won't even compile. Same problem as in your last post:
long long C[n];
doesn't work, because the compiler cannot allocate space for a quantity n that is unknown at compile time. Nor will
int arr[n+1][n+1];
work for the same reason. So fix that first and you will at least be able to run your code.
Next you will have to improve your algorithm. At the moment you are trying to solve the problem in a brute force way. That won't work within the given time limit -- and that's what the whole exercise is about. So start looking for a smarter way to approach things.
The first thing that comes to mind is that there is exactly one node with maximum value M. All nodes not linked to M will be assigned M's index. That's why index 5 appears three times in your example. So determining the maximum node and assigning it's index to all but that node itself is a reasonable default initialization.
Next find all the set of nodes that are linked to the maximum node M and let's call it Mset. (Your examples tells me that you interpret the term "linked" as non-transitive, i.e. A is linked to B only if there is an explicit link entry between them. As an extension to that exercise try to solve it for the case where "linked" is interpreted in a transitive manner, i.e. A is linked to B if there is a sequence of links that leads from node A to B). All these nodes in Mset must be assigned a value that is different from the above default.
To find that value for node x you scan the node list and find the highest value node that is not x or the maximum node M. The tricky part is to do that efficiently. The solution is not that hard to find and that is your part. (Tip: What if your nodes would be sorted by value?)
Hope that gets you on the right path.