模拟代码求调~ qwq
查看原帖
模拟代码求调~ qwq
372172
Q__A__Q楼主2022/6/18 23:14

rt

// Problem: P8404 [CCC 2022 J5] Square Pool
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P8404
// Memory Limit: 128 MB
// Time Limit: 1000 ms
// Date: 2022-06-18 18:35:53
// Author: fzy
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int maxn=2e2+10;
const int inf=1e9+7;
int n,t,y[maxn],x[maxn],tmp[maxn],ans;

inline int read() {
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-')w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}

inline bool cmp(int x,int y) {
	return x<y;
}

signed main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),t=read();
	for(int i=1;i<=t;++i) x[i]=read(),y[i]=read();
	for(int i=1;i<=t;++i) 
		for(int j=i+1;j<=t;++j) {
			memset(tmp,0,sizeof(tmp));
			int xx1=x[i],xx2=x[j],d1=abs(xx1-xx2),tot=0;
			for(int k=1;k<=t;++k) {
				if(x[k]>xx1&&x[k]<xx2) tmp[++tot]=y[k];
			}
			sort(tmp+1,tmp+tot+1,cmp);
			for(int k=1;k<tot;++k) 
				if(tmp[k+1]-tmp[k]>=d1) {
					ans=max(ans,d1);
					continue;
				}
		}
	printf("%d\n",ans);
	return 0;
}
2022/6/18 23:14
加载中...