F. Custom-Made Clothes
二分,由于
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define inf 0x3f3f3f3f
const int mod = 998244353;
const int N = 1e3 + 10;
int n, k;
int ask(int i,int j,int x){
cout << "? " << i << " " << j << " " << x << endl;
int ans; cin >> ans;
return ans;
}
bool check(int mid){
int res = 0;
int x = n, y = 1;
while(x >= 1 && y <= n){
if(ask(x,y,mid)){
res += x;
y ++;
}else{
x --;
}
}
return (res >= k);
}
void solve(){
cin >> n >> k;
k = n * n - k + 1;
int l = 0 , r = n * n ;
while(l + 1 < r){
int mid = (l + r) >> 1;
if(check(mid)) r = mid;
else l = mid;
}
cout << "! " << r;
}
signed main(){
//ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int _ = 1;
//cin >> _;
while(_--) solve();
return 0;
}