# Untitled

unknown
plain_text
19 days ago
3.0 kB
1
Indexable
Never
```#include<bits/stdc++.h>

#define ll long long
#define pp push_back
//#define endl '\n'
#define all(x) x.begin(),x.end()
#define ld long double
#define PI acos(-1)
#define sin(a) sin((a)*PI/180)
#define cos(a) cos((a)*PI/180)
#define ones(x) __builtin_popcountll(x)
//#define int ll

using namespace std;

void Drakon() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef Clion
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}

unsigned long long inf = 1e10;
const double EPS = 1e-6;
const int MOD = 1000000007, N = 200005, LOG = 25;

ll mul(const ll &a, const ll &b) {
return (a % MOD + MOD) * (b % MOD + MOD) % MOD;
}

ll add(const ll &a, const ll &b) {
return (a + b + 2 * MOD) % MOD;
}

ll pw(ll x, ll y) {
ll ret = 1;
while (y > 0) {
if (y % 2 == 0) {
x = mul(x, x);
y = y / 2;
} else {
ret = mul(ret, x);
y = y - 1;
}
}
return ret;
}

ll ask(int a, int b, int c, int d){
cout << "? " << a + 1 << " " << b + 1 << " " << c + 1 << " " << d + 1 << endl;
ll ans;
cin >> ans;
return ans;
}

int n;
ll k;
map<pair<int, int>, ll> cost;

void dfs(int u, int p1, int p2, ll edge) {

ll ret = ask(p2, u, p2, p1) - 2 * edge;
cost[{u, p1}] = cost[{p1, u}] = ret;

if(v.first == p1)continue;
dfs(v.first, u, p1, ret);
}
}

void solve() {
cin >> n >> k;
for (int i = 0; i < n - 1; ++i) {
int u, v;
cin >> u >> v;
u--, v--;
}

int root = 0;
for (int i = 0; i < n; ++i) {
root = i;
break;
}
}

ll sum = (r1 + r2) / 3;
for (int i = 2; i < adj[root].size(); ++i) {
}

if(v.first == root)continue;
dfs(v.first, adj[root][0].first, root, r1 - sum);
}
if(v.first == root)continue;
dfs(v.first, adj[root][1].first, root, r2 - sum);
}

for (int i = 0; i < n; ++i) {
v.second = cost[{i, v.first}];
}
}

}

signed main() {
Drakon();
int t = 1;
cin >> t;
while (t--) {
solve();
}
}```