fix some bug and final version for AI contest