当前位置:网站首页>牛客小白月赛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; }
边栏推荐
- Cross border independent station language Unicode to Hebrew
- Yurun multidimensional makes efforts in the charity field and bravely resists the corporate public welfare banner
- R语言使用自定义函数编写深度学习Leaky ReLU激活函数、并可视化Leaky ReLU激活函数
- 基于STM32F103ZET6库函数定时器中断实验
- Test dble split function execution + import time-consuming shell script reference
- SSH协议学习笔记
- The dplyr package filter function of R language filters the data in dataframe data through combinatorial logic (and logic). The content of one field is equal to one of the specified vectors, and the v
- 第42期:MySQL 是否有必要多列分区
- Custom handlerinterceptor interceptor for user authentication
- 3h精通OpenCV(五)-透视变换
猜你喜欢

mysql. What is the concept of sock

基于STM32F103ZET6库函数串口实验

Distributed | several steps of rapid read / write separation

Issue 42: is it necessary for MySQL to have multiple column partitions

OpenFeign使用步骤 轮询策略与权重 log4j使用 openFeign拦截器的配置

Matlab farthest point sampling (FPS)

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

Selenium upload file

PCB frame drawing - ad19

小程序容器是什么技术?能助力物联网企业红海突围?
随机推荐
How to create a virtual image
Analyze the implementation principle of zero copy mechanism, applicable scenarios and code implementation
R language uses GLM of mass package The Nb function establishes the negative binomial generalized linear model, and the summary function obtains the summary statistical information of the negative bin
Face recognition 4- research on Baidu commercial solutions
reflex
What are the usage scenarios for locks in MySQL
双亲委派机制
MaxCompute Studio
与爱同行,育润走进贫困家庭,助推公益事业
位图的详细介绍及模拟实现
Graduation season | Huawei experts teach interview tips: how to get a high salary offer from a large factory?
Web Scraping with Beautiful Soup for Data Scientist
使用autoIt 上传文件
阿里云不同账号新旧服务器镜像迁移数据迁移同步
Maidong Internet won the bid of Dajia Insurance Group
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
Mysql database literacy, do you really know what a database is
分割回文串[dp + dfs组合]
R language uses user-defined functions to write deep learning linear activation functions and visualize linear activation functions
What technology is an applet container? Can it help Internet of things enterprises break through the red sea?