当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
Say sqlyog deceived me!
On the discrimination of "fake death" state of STC single chip microcomputer
Bbox regression loss function in target detection -l2, smooth L1, IOU, giou, Diou, ciou, focal eiou, alpha IOU, Siou
Detailed explanation of platform device driver architecture in driver development
JVM命令之 jstat:查看JVM統計信息
Vscode for code completion
[FPGA tutorial case 13] design and implementation of CIC filter based on vivado core
Subghz, lorawan, Nb IOT, Internet of things
安装VMmare时候提示hyper-v / device defender 侧通道安全性
Financial risk control practice - decision tree rule mining template
随机推荐
The boss always asks me about my progress. Don't you trust me? (what do you think)
Personal imitation SSM framework
Database notes 04
进程间通信之共享内存
jmeter 函数助手 — — 随机值、随机字符串、 固定值随机提取
window下面如何安装swoole
JVM命令之 jstack:打印JVM中线程快照
693. 行程排序
10W word segmentation searches per second, the product manager raised another demand!!! (Collection)
话说SQLyog欺骗了我!
Change the original style of UI components
JVM命令之 jstat:查看JVM统计信息
Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
关于STC单片机“假死”状态的判别
Financial risk control practice - decision tree rule mining template
SAP Spartacus checkout 流程的扩展(extend)实现介绍
go-microservice-simple(2) go-Probuffer
Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
JVM监控及诊断工具-命令行篇
那些自损八百的甲方要求