移动端模板,婚纱网站目录优化,wordpress推广网站插件,保定网站模板建站Problem - G - Codeforces 思路#xff1a;想了挺长时间的#xff0c;一直没想到一个简便的方法在瞎搞。我们发现对于某个点来说#xff0c;其他的点如果能够跟他匹配#xff0c;那么一定在这8个方向上#xff0c;而同时这8个方向其实对应这4条直线#xff0c;假设点为(x…Problem - G - Codeforces 思路想了挺长时间的一直没想到一个简便的方法在瞎搞。我们发现对于某个点来说其他的点如果能够跟他匹配那么一定在这8个方向上而同时这8个方向其实对应这4条直线假设点为(x1,y1)那么直线为xx1,yy1,yxy1-x1,y-xx1y1那么在求能够跟当前点匹配的点时只需要看一下在这四条直线上的点的数量假设为a,b,c,d那么产生的贡献就是a-1b-1c-1d-1同时我们还需要考虑会不会重复就是一个点会不会跟一个点匹配两次因为保证了没有重复点所以前两条直线是不会重复的那么后两条直线也是不会重复的只有当x10,y10时后两个直线重复但是在算贡献是一定不会同时添加
// Problem: G. The Morning Star
// Contest: Codeforces - Codeforces Round 886 (Div. 4)
// URL: https://codeforces.com/contest/1850/problem/G
// Memory Limit: 256 MB
// Time Limit: 2000 ms#includebits/stdc.h
#includesstream
#includecassert
#define fi first
#define se second
#define i128 __int128
using namespace std;
typedef long long ll;
typedef double db;
typedef pairint,int PII;
const double eps1e-7;
const int N5e57 ,M5e57, INF0x3f3f3f3f,mod1e97,mod1998244353;
const long long int llINF0x3f3f3f3f3f3f3f3f;
inline ll read() {ll x0,f1;char cgetchar();while(c0||c9) {if(c-) f-1;cgetchar();}
while(c0c9) {x(ll)x*10c-0;cgetchar();} return x*f;}
inline void write(ll x) {if(x 0) {putchar(-); x -x;}if(x 10) write(x / 10);putchar(x % 10 0);}
inline void write(ll x,char ch) {write(x);putchar(ch);}
void stin() {freopen(in_put.txt,r,stdin);freopen(my_out_put.txt,w,stdout);}
bool cmp0(int a,int b) {return ab;}
templatetypename T T gcd(T a,T b) {return b0?a:gcd(b,a%b);}
templatetypename T T lcm(T a,T b) {return a*b/gcd(a,b);}
void hack() {printf(\n----------------------------------\n);}int T,hackT;
int n,m,k;
PII w[N];void solve() {nread();for(int i1;in;i) w[i].firead(),w[i].seread();ll res0;mapint,int a,b,c,d;for(int i1;in;i) {a[w[i].fi];b[w[i].se];c[w[i].fiw[i].se];d[w[i].se-w[i].fi];}for(int i1;in;i) {a[w[i].fi]--;b[w[i].se]--;c[w[i].fiw[i].se]--;d[w[i].se-w[i].fi]--;resa[w[i].fi]b[w[i].se]c[w[i].fiw[i].se]d[w[i].se-w[i].fi];}printf(%lld\n,res*2);
} int main() {// init();// stin();// ios::sync_with_stdio(false); scanf(%d,T);// T1; while(T--) hackT,solve();return 0;
}