当前位置:网站首页>Niuke Xiaobai monthly race 52 E group logarithmic sum (inclusion exclusion theorem + dichotomy)
Niuke Xiaobai monthly race 52 E group logarithmic sum (inclusion exclusion theorem + dichotomy)
2022-06-29 17:56:00 【eva_ can(not)survive】
Sign in — major IT Written interview preparation platform _ Cattle from Niuke.com is the magic weapon of Internet Job Hunting ,C++、Java、 front end 、 product 、 Operational skills learning / Test preparation / Job search question bank , Online Baidu Alibaba Tencent Netease and other Internet famous enterprises written interview simulation test practice , Discuss the classic test questions with Niu Ren , Improve your technical ability in an all-round way
https://ac.nowcoder.com/acm/contest/11229/E You can put all the numbers directly into a sequence , Then enumerate each number , Through inclusion and exclusion, we can know the number that satisfies the condition in the total sequence - The number in the child , You can get the combination of the numbers , And then divide by 2 that will do
#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; }
边栏推荐
- Bloom filter:
- Yurun multidimensional makes efforts in the charity field and bravely resists the corporate public welfare banner
- QQ如何开通在线客服
- What are the usage scenarios for locks in MySQL
- Createstore for Redux source code analysis
- phpunit骚操作之静态类的部分mock
- POJ 1975 (传递闭包)
- [webdriver] upload files using AutoIT
- 回文子串的最大长度(字符串哈希+二分)
- selenium上传文件
猜你喜欢

Distributed | several steps of rapid read / write separation

Openfeign use step polling strategy and weight log4j configuration of openfeign interceptor

Inherit Chinese virtues, pay attention to the health of the middle-aged and the elderly, and Yurun milk powder has strong respect for the elderly

牛客小Bai月赛52 D 环上食虫(尺取+st表)

面试中问最常问的海量数据处理你拿捏了没?

Parental delegation mechanism

布隆过滤器:

How to use the chart control of the b/s development tool devextreme - customize the axis position?

MATLAB 最远点采样(FPS)

ISO 32000-2 国际标准7.7
随机推荐
Basic operations such as MySQL startup under Windows platform
lodash深拷贝使用
Inherit Chinese virtues, pay attention to the health of the middle-aged and the elderly, and Yurun milk powder has strong respect for the elderly
Mac installation php7.2
基于注解和拦截器防止表单重复提交
Two controller layer interface authentication methods
Matlab farthest point sampling (FPS)
Function independent watchdog (iwdg) experiment based on stm32f103zet6 Library
Maxcompute string replacement function -replace
让 Google 搜索到自己的博客
reflex
How to create a virtual image
js两个一维数组合并并去除相同项(整理)
Cross border independent station language Unicode to Hebrew
分布式 | 几步快速拥有读写分离
Timer interrupt experiment based on stm32f103zet6 library function
Segment tree and tree array template (copy and paste are really easy to use)
Yurun multidimensional makes efforts in the charity field and bravely resists the corporate public welfare banner
两种Controller层接口鉴权方式
mongoTemplate - distinct 使用