欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > 【回收站选址】

【回收站选址】

2024/10/24 18:22:30 来源:https://blog.csdn.net/m0_73669127/article/details/142071398  浏览:    关键词:【回收站选址】

题目


在这里插入图片描述
在这里插入图片描述
在这里插入图片描述



代码


#include <bits/stdc++.h>
using namespace std;
const int R = 2e9+1; 
typedef long long LL;
unordered_set<LL> s;
int piles[5];
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int dx1[4] = {-1, -1, 1, 1}, dy1[4] = {-1, 1, -1, 1};bool check(LL r)
{int y = r / R;int x = r % R;for(int i = 0; i < 4; i++){LL t = r + dx[i] + dy[i] * R;if(!s.count(t)) return false;}return true;
}int rate(LL r)
{int retval = 0;int y = r / R;int x = r % R;for(int i = 0; i < 4; i++){LL t = r + dx1[i] + dy1[i] * R;if(s.count(t)) retval++;}return retval;
}
int main()
{int n;cin >> n;for(int i = 1; i <= n; i++){int x, y;cin >> x >> y;x += 1e9; y += 1e9;LL r = 1ll * y * R + x;s.insert(r);}for(auto c : s){if(check(c)){piles[rate(c)]++;}}for(int i = 0; i < 5; i++){cout << piles[i] << "\n";}return 0;
}


爆int漏掉的可能地方

  1. 函数返回值
  2. 函数传参
  3. 多项和
  4. 乘积

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com