Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-D. Restore Permutation-构造+树状数组 [Problem Description] ​ 给你一个长度为\(n\)的数组,第\(i\)个元素\(s_i\)表示一个排列中第\(i\)个元素之前,并且小于\(p_i\)的元素的和.求出满足此条件的排列. [Solution] ​ 假设\(n=5\),\(s[]=\{0,0,3,7,3\}\).从后往前看…
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-C. Magic Grid-构造 [Problem Description] ​ 给你一个\(n\),构造一个\(n\times n\)的矩阵,使其满足任意一行,或一列的异或值相同.保证\(n\)能被\(4\)整除. [Solution] ​ 可以发现,从\(0\)开始,每\(4\)个连续数的异或值为\(0\),所以可以很容易使得每一行的异或值等于\(0\). ​ 列…
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)-E. Let Them Slide-思维+数据结构 [Problem Description] ​ \(n\times w\)的方格中,每一行有\(cnt_i\)个数字,每一行的数字都连续的放在一起,但是可以任意的平移.问每一列的最大和为多少. [Solution] ​ 最直观的想法是对于每一列\(j\),计算出每一行中的一个区间最大值,此区间长度为\(len=w-c…
题意:https://codeforc.es/contest/1208/problem/E 现有n行w列的墙,每行有一排连续方块,一排方块可以左右连续滑动,且每个方块都有一个价值,第i 列的价值定义为这列的方块的价值和.求1到w列中每列的最大价值.注:如果一个位置没有方块,那么这个位置的价值为0 思路: 直接RMQ+差分数组即可. #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include <cstdio>//sprintf i…
 题意:问你有n个长度总和为n的数组 你可以移动数组 但不能移出长度为w的矩形框 问你每一列的最大值是多少? 思路:只有一次询问 我们可以考虑差分来解决 然后对于每一行数组 我们可以用数据结构维护一下区间最大值 #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double eps = 1e-6; const int N = 1e6+7; typedef long long ll; c…
传送门 A. XORinacci 手玩三四项发现序列就是 $a,b,a\ xor\ b,a,b,...$,直接输出即可 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; typedef long long ll; inline int read() { ,f=; char ch…
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;long long ans[1000007];vector<pair<int,int> >add[1000007],remv[1000007];multiset<int>s[1000007];//也可以用deque,rmq等数据结构实现,多重集自带排序int main(){ int n,w; cin>>n&…
G. Polygons Description You are given two integers…
1208 F 大意:  给定序列$a$, 求$\text{$a_i$|$a_j$&$a_k$}(i<j<k)$的最大值 枚举$i$, 从高位到低位贪心, 那么问题就转化为给定$x$, 求判断$[i+1,n]$内二进制包含$x$的个数是否不少于$2$, 可以对每个状态, 维护最远的两个位置即可. #include <iostream> #include <sstream> #include <algorithm> #include <cstdio…