当前位置:网站首页>牛客小白月赛52 E 分组求对数和(容斥定理+二分)
牛客小白月赛52 E 分组求对数和(容斥定理+二分)
2022-06-29 17:47:00 【eva_can(not)survive】
登录—专业IT笔试面试备考平台_牛客网牛客网是互联网求职神器,C++、Java、前端、产品、运营技能学习/备考/求职题库,在线进行百度阿里腾讯网易等互联网名企笔试面试模拟考试练习,和牛人一起讨论经典试题,全面提升你的技术能力
https://ac.nowcoder.com/acm/contest/11229/E可以将所有数直接搞到一个序列中,然后再枚举每一个数字,通过容斥可以知道在总的序列中满足条件的数字-该小朋友中的数字,就可得该数字的组合,最后再除以2即可
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <map> #include <queue> #define lowbit(x) ((x)&(-x)) using namespace std; using ll = long long; using ull = unsigned long long; using P = pair<int,int>; const int MAXN=1e6+5; const int INF=0x3f3f3f3f; const ll NNF=0x3f3f3f3f3f3f3f3f; const int N=1e5; int n,k; const int mod=998244353; vector<int> s; vector<int> rec[MAXN]; void solve(){ scanf("%d %d",&n,&k); int t,tmp; for(int i=1;i<=n;i++){ scanf("%d",&t); for(int j=1;j<=t;j++){ scanf("%d",&tmp); rec[i].push_back(tmp); s.push_back(tmp); } sort(rec[i].begin(),rec[i].end()); } ll ans=0; sort(s.begin(),s.end()); for(int i=1;i<=n;i++){ int res=rec[i].size(); for(int j=0;j<res;j++){ int tmp1=rec[i].end()-lower_bound(rec[i].begin(),rec[i].end(),k-rec[i][j]); int tmp2=s.end()-lower_bound(s.begin(),s.end(),k-rec[i][j]); ans+=tmp2-tmp1; } } printf("%lld",ans/2%mod); } int main(){ solve(); return 0; }
边栏推荐
- Does MySQL support foreign keys
- Selenium file upload method
- VB. Net read / write NFC ntag tag source code
- How to solve MySQL 1045 error in Linux
- 【WebDriver】使用AutoIt上传文件
- Digital twin energy system, creating a "perspective" in the low-carbon era
- OpenFeign使用步骤 轮询策略与权重 log4j使用 openFeign拦截器的配置
- 与爱同行,育润走进贫困家庭,助推公益事业
- reflex
- Parental delegation mechanism
猜你喜欢

布隆过滤器:

基于注解和拦截器防止表单重复提交

如何使用B/S开发工具DevExtreme的图表控件 - 自定义轴位置?

Let's start with a bug that was cheated by the app store

Face recognition 4- research on Baidu commercial solutions

How to solve MySQL 1045 error in Linux
![[the sixth operation of modern signal processing]](/img/49/7844a00077e56fd4d73e3ba515f8a6.png)
[the sixth operation of modern signal processing]

PCB frame drawing - ad19

Distributed | several steps of rapid read / write separation

Selenium upload file
随机推荐
ISO 32000-2 国际标准7.7
3h精通OpenCV(八)-形状检测
测试dble split功能执行+导入耗时shell脚本参考
Top 30 open source software
What value can SRM systems bring to the enterprise?
The R language inputs the distance matrix to the hclust function for hierarchical clustering analysis. The method parameter specifies the distance calculation method between two combined data points,
The aggregate function in the epidisplay package of R language divides numerical variables into different subsets based on factor variables, and calculates the summary statistics and aggregate data. W
力扣每日一题 06.29 两数相加
MATLAB 最远点采样(FPS)
Maidong Internet won the bid of Dajia Insurance Group
Timer interrupt experiment based on stm32f103zet6 library function
基于STM32F103ZET6库函数独立看门狗(IWDG)实验
双亲委派机制
selenium上传文件
PWM output experiment based on stm32f103zet6 library function
How to create a virtual image
Function independent watchdog (iwdg) experiment based on stm32f103zet6 Library
What is the SRM system? How do I apply the SRM system?
Repair of JSON parsing errors in a collection
国外LEAD赚钱,做个网站真的很简单