首页 > 代码库 > The Place I Paste Code
The Place I Paste Code
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <algorithm>using namespace std;const int MaxN = 50000 + 5;int n, m, a, b, c, d, Ans, MaxNum;int Root[MaxN];void Add(int x, int s, int t, int l, int r, int Num) { if (l <= s && r >= t) { Insert(x, 1, MaxNum, Num); return; } int m = (s + t) >> 1; if (l <= m) Add(x << 1, s, m, l, r, Num); if (r >= m + 1) Add(x << 1 | 1, m + 1, t, l, r, Num); Update(x);}int main() { scanf("%d%d", &n, &m); MaxNum = n * 2 + 1; for (int i = 1; i <= m; ++i) { scanf("%d%d%d%d", &a, &b, &c, &d); if (a == 1) { d = - d + n + 1; Add(1, 1, n, b, c, d); } else { Ans = GetKth(b, c, d); printf("%d\n", -Ans + n + 1); } } return 0;}
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <algorithm>using namespace std;const int MaxN = 50000 + 5;int n, m, a, b, c, d, Ans, MaxNum;int Root[MaxN];void Add(int x, int s, int t, int l, int r, int Num) { if (l <= s && r >= t) { Insert(x, 1, MaxNum, Num); return; } int m = (s + t) >> 1; if (l <= m) Add(x << 1, s, m, l, r, Num); if (r >= m + 1) Add(x << 1 | 1, m + 1, t, l, r, Num); Update(x);}int main() { scanf("%d%d", &n, &m); MaxNum = n * 2 + 1; for (int i = 1; i <= m; ++i) { scanf("%d%d%d%d", &a, &b, &c, &d); if (a == 1) { d = - d + n + 1; Add(1, 1, n, b, c, d); } else { Ans = GetKth(b, c, d); printf("%d\n", -Ans + n + 1); } } return 0;}
The Place I Paste Code
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。