The problem is that std::list is a linked list and as such, normally you cannot access indexed element (not in constant time anyway).
I believe what you wanted to use was std::vector instead.