goextreme's blog

By goextreme, 17 months ago, In English

i was solving this problem

i got wrong answer many times(you can refer to my last submissions) on test 1, but when i checked myself with sample test-cases i got right answers.

I wonder why?

my last submission

can someone explain reason or give some hints , thanks in advance

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
17 months ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

because in the test case 2, which offers a grid with size of 5x3 and the king is located in [5,1]. According to your codecout<<"? "<<1<<" "<<k+1<<endl;, it will output "? 1 5" where 5>3, so its illegal.

by the way, endl will flush the output automatically, so you dont need to write cout.flush(); again.