当前位置:网站首页>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; }
边栏推荐
- [try to hack] cookies and sessions
- mysql. What is the concept of sock
- 基于STM32F103ZET6库函数PWM输出实验
- Matlab farthest point sampling (FPS)
- What is the MySQL query view command
- js两个一维数组合并并去除相同项(整理)
- 软件快速交付真的需要以安全为代价吗?
- Web Scraping with Beautiful Soup for Data Scientist
- Force deduction daily question 06.29 add two numbers
- What is the function of MySQL cursors
猜你喜欢

Basic operations such as MySQL startup under Windows platform

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

Does MySQL support foreign keys

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

【目标跟踪】|stark配置 win otb

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

Software testing - you may not understand the basic theoretical knowledge

Selenium file upload method

selenium上传文件

Visio annotation, annotation location
随机推荐
关于日期相加减问题
Uploading files using AutoIT
Selenium file upload method
Bloom filter:
mongoTemplate - distinct 使用
How MySQL queries character set codes of tables
Mysql database literacy, do you really know what a database is
如何使用B/S开发工具DevExtreme的图表控件 - 自定义轴位置?
Spingmvc requests and responses
Visual studio plug-in coderush officially released v22.1 -- visual tool for optimizing debugging
分割回文串[dp + dfs组合]
Professor of Cambridge University: eating breakfast often is harmful and dangerous. - you know what
DevCloud加持下的青软,让教育“智”上云端
kubekey2.2.1 kubernetes1.23.7离线包制作+harbor部暑并上传镜像
How to use the chart control of the b/s development tool devextreme - customize the axis position?
MaxCompute Studio
What are the usage scenarios for locks in MySQL
基于gis三维可视化的智慧城市行业运用
小程序容器是什么技术?能助力物联网企业红海突围?
育润多维发力慈善领域,勇抗企业公益大旗