当前位置:网站首页>Niuke Xiaobai monthly race 52 E. sum logarithms in groups (two points & inclusion and exclusion)
Niuke Xiaobai monthly race 52 E. sum logarithms in groups (two points & inclusion and exclusion)
2022-07-07 06:18:00 【Harris-H】
Niuke Xiaobai moon race 52 E. Sum logarithms in groups ( Two points & A class )
First save all the numbers in an array , Then use two dimensions vector Save the number of each group .
According to the thought of tolerance and exclusion , For each number, first find all the satisfied numbers by dichotomy, and then subtract the number in your group .
Those in my group are corresponding vector Two points in .
Time complexity : O ( m l o g m ) O(mlogm) O(mlogm)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n, k;
vector<int> ve[1000009], a;
void solved() {
scanf("%d%d", &n, &k);
int m;
for(int i = 0; i < n; i ++) {
scanf("%d", &m);
int x;
while(m --) {
scanf("%d", &x);
ve[i].push_back(x);
a.push_back(x);
}
sort(ve[i].begin(), ve[i].end());
}
sort(a.begin(), a.end());
ll ans = 0;
for(int i = 0; i < n; i ++) {
m = ve[i].size();
for(int j = 0; j < m; j ++) {
int x = ve[i][j], y = k - x;
ans +=
(a.end() - upper_bound(a.begin(), a.end(), y - 1)) -
(ve[i].end() - upper_bound(ve[i].begin(), ve[i].end(), y - 1));
}
}
ans /= 2;
cout << ans % 998244353;
}
int main() {
// int ttx; cin >> ttx; while(ttx --)
solved();
return 0;
}
边栏推荐
- How to keep accounts of expenses in life
- Talking about reading excel with POI
- Solve pod install error: FFI is an incompatible architecture
- Experience of Niuke SQL
- 3428. Put apples
- ST表预处理时的数组证明
- Financial risk control practice - decision tree rule mining template
- Detailed explanation of platform device driver architecture in driver development
- Bbox regression loss function in target detection -l2, smooth L1, IOU, giou, Diou, ciou, focal eiou, alpha IOU, Siou
- QT console output in GUI applications- Console output in a Qt GUI app?
猜你喜欢

一名普通学生的大一总结【不知我等是愚是狂,唯知一路向前奔驰】

开发者别错过!飞桨黑客马拉松第三期链桨赛道报名开启

go-microservice-simple(2) go-Probuffer

laravel 使用腾讯云 COS5全教程

Vscode for code completion

JMeter's own functions are not enough? Why don't you develop one yourself

Career experience feedback to novice programmers

Introduction to yarn (one article is enough)

Mac version PHP installed Xdebug environment (M1 version)

Jinfo of JVM command: view and modify JVM configuration parameters in real time
随机推荐
3428. Put apples
go-microservice-simple(2) go-Probuffer
VScode进行代码补全
cf:C. Column Swapping【排序 + 模拟】
关于STC单片机“假死”状态的判别
POI excel export, one of my template methods
Rk3399 platform development series explanation (interruption) 13.10, workqueue work queue
职场经历反馈给初入职场的程序员
jmeter 函数助手 — — 随机值、随机字符串、 固定值随机提取
MFC BMP sets the resolution of bitmap, DPI is 600 points, and gdiplus generates labels
Swagger3 configuration
Personal imitation SSM framework
Storage of dental stem cells (to be continued)
一名普通学生的大一总结【不知我等是愚是狂,唯知一路向前奔驰】
高并发大流量秒杀方案思路
Talking about reading excel with POI
可极大提升编程思想与能力的书有哪些?
Rk3399 platform development series explanation (WiFi) 5.52. Introduction to WiFi framework composition
牛客小白月赛52 E.分组求对数和(二分&容斥)
A very good JVM interview question article (74 questions and answers)