当前位置:网站首页>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; }
边栏推荐
- 最长异或路径(dfs+01trie)
- ISO 32000-2 international standard 7.7
- Visual Studio插件CodeRush正式发布v22.1——优化调试可视化工具
- MaxCompute Studio
- phpunit骚操作之静态类的部分mock
- 国外LEAD赚钱,做个网站真的很简单
- Split palindrome string [dp + DFS combination]
- 从一个被应用商店坑了的BUG说起
- What is the SRM system? How do I apply the SRM system?
- 金鱼哥RHCA回忆录:DO447构建高级作业工作流--使用事实缓存提高性能
猜你喜欢

2022春夏系列 KOREANO ESSENTIAL重塑时装生命力

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

Image migration and data migration synchronization of old and new servers with different Alibaba cloud accounts

What are the usage scenarios for locks in MySQL

面试中问最常问的海量数据处理你拿捏了没?
![[webdriver] upload files using AutoIT](/img/69/8c27626d515976b47f1df4831d09c8.png)
[webdriver] upload files using AutoIT

布隆过滤器:

从一个被应用商店坑了的BUG说起

ISO 32000-2 international standard 7.7

Top 30 open source software
随机推荐
QQ如何开通在线客服
关于日期相加减问题
剑指 Offer 13. 机器人的运动范围 (BFS)
剖析下零拷贝机制的实现原理,适用场景和代码实现
Does rapid software delivery really need to be at the cost of security?
图像特征计算与表示——基于内容的图像检索
[webdriver] upload files using AutoIT
Issue 42: is it necessary for MySQL to have multiple column partitions
SCM系统是什么?供应链管理系统有哪些优势?
金鱼哥RHCA回忆录:DO447构建高级作业工作流--使用事实缓存提高性能
Web Scraping with Beautiful Soup for Data Scientist
What are the usage scenarios for locks in MySQL
数字孪生能源系统,打造低碳时代“透视”眼
SSH协议学习笔记
What value can SRM systems bring to the enterprise?
selenium 组合键操作
布隆过滤器:
Openfeign use step polling strategy and weight log4j configuration of openfeign interceptor
Selenium key combination operation
R language ggplot2 visualization: use the patchwork package (directly use the plus sign +) to horizontally combine a ggplot2 visualization result and a plot function visualization result to form the f