Last active
December 9, 2018 16:46
-
-
Save chermehdi/512de6f6145e035af6c490e4c13c2f1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MaxAndElectricalPanel { | |
public void solve(int testNumber, FastReader in, PrintWriter out) { | |
int n; | |
int INC; | |
int increment(int cur) { | |
return Math.min(n, cur + INC); | |
} | |
int decrement(int cur) { | |
return Math.max(1, cur - INC); | |
} | |
public void solve(int testNumber, FastReader in, PrintWriter out) { | |
n = in.nextInt(); | |
int c = in.nextInt(); | |
int cur = 1; | |
INC = (int) (Math.sqrt(150000) + 1); | |
while (true) { | |
out.println(1 + " " + cur); | |
out.flush(); | |
int got = in.nextInt(); | |
if (got == 0) { | |
cur = increment(cur); | |
} else { | |
if(cur == 1) { | |
break; | |
} | |
if (INC == 1) { | |
break; | |
} | |
cur = decrement(cur); | |
INC = 1; | |
out.println(2); | |
out.flush(); | |
} | |
} | |
out.println(3 + " " + cur); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment