0%

Codeforces Round 1046 (Div. 2)——D. For the Champion

思路讲解

这种题目就是要多想,多写,想办法去除绝对值。

把式子写下来。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    ll dis=ask('U',mod);
sort(all(A),[&](Point a,Point b){
return 2*2*mod-a.x()-a.y() < 2*2*mod-b.x()-b.y();
});
Point a=A[0];
// 知道了x+y是多少
// mod*2+X+mod*2+Y-a.x()-a.()=dis
ll XY=dis-2*2*mod+a.x()+a.y();
// #ifdef LOCAL
// debug(XY);
// #endif
ask('D',mod);
ask('D', mod);
ask('D',mod);
ll dis2=ask('D', mod);
sort(all(A),[&](Point a,Point b){
return 2*2*mod-a.x()+a.y() < 2*2*mod-b.x()+b.y();
});
a=A[0];
// X+2*mod-x+y-(Y-2*mod)=dis2
// dis2+x-y-2*2*mod
ll X_Y=dis2+a.x()-a.y()-2*2*mod;

AC代码

https://codeforces.com/contest/2136/submission/336079080

心路历程(WA,TLE,MLE……)