Yeah... umm that's called the Mew glitch.
It doesn't have to be that trainer. Any trainer that sees you RIGHT when you go on screen.
And it's not just Those PKMN, either. So long as the 1st PKMN in your Party has a SPCL stat of 17
And it's not just Mew.
Different Pokemon appear with different Special Stats.
This is the SPCL stat table for YELLOW not Red or Blue.