You can use a 1xn matrix (i.e. a vector) where n is the total number of NPCs, that stores the 1-or-0 values, so the position within the vector is related to the NPC number.
For instance, in pseudo-code:
already_talked = {1,0,1...n}
//where n is the total number of NPCs
So the first value in the vector relates to NPC1, the second value relates to NPC2, and so on.