链接 #include <iostream> #include <algorithm> using namespace std; const int N = 1e4 + 10; int a[N], b[N]; int main() { int n, k; scanf("%d %d", &n, &k); for(int i = 1; i <= n - 1; i++) { printf("and %d %d\n", i, i+1); fflush(stdout); int x; scanf("%d", &x); printf("or %d %d\n", i, i+1); fflush(stdout); int y; scanf("%d", &y); a[i] = x + y; } printf("and 1 3\n"); fflush(stdout); int x; scanf("%d", &x); printf("or 1 3\n"); fflush(stdout); int y; scanf("%d", &y); int tmp = x + y; b[1] = (a[1] - a[2] + tmp) / 2; for(int i = 2; i <= n; i++) b[i] = a[i-1] - b[i-1]; sort(b+1, b+1+n); printf("finish %d\n", b[k]); return 0; }