Solved Pro.ID Title Ratio(Accepted / Submitted)
  1001 Salty Fish 16.28%(7/43)
 OK 1002 Nonsense Time                暴力 7.88%(57/723)
  1003 Milk Candy 12.90%(4/31)
  1004 Speed Dog 26.97%(48/178)
  1005 Snowy Smile 8.52%(225/2640)
  1006 Faraway 27.92%(98/351)
  1007 Support or Not 8.33%(3/36)
  1008 TDL 27.63%(921/3333)
  1009 Three Investigators 7.14%(1/14)
  1010 Ridiculous Netizens            点分治 38.71%(24/62)
  1011 11 Dimensions 13.47%(64/475)
  1012 Stay Real 45.04%(1044/2318)

1002 Nonsense Time

题意

给定一个长度n($n \le 50000$)的排列$p_1, p_2, ... ,p_n$,给定一个长度为n的排列$a_1, a_2, ... ,a_n$.

初始排列p是不可见的,从1到n,第$p_{a_i}$个可见,输出此时可见p的LIS。

数据保证纯随机。

思路

由于是随机,所以有人证明lis的期望是O($\sqrt{n}$)。

所以我们利用时间倒流技术,从后往前做。

记录一个LIS,如果要删除的数是LIS上的,就重新算一个LIS,如果要删的数不再LIS上,那什么事也没发生。

复杂度 = $ n \times \lgroup \frac{1}{\sqrt{n}} \times n \times \log n + \frac{1}{\sqrt{n}} \rgroup$

   = $n \times \sqrt{n} \times \log n + \sqrt{n}$

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize(4)
#include <algorithm>
#include <iterator>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <cassert>
// #include<bits/extc++.h>
// using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define fi first
#define se second
#define debug(x) cerr<<#x << " := " << x << endl;
#define bug cerr<<"-----------------------"<<endl;
#define FOR(a, b, c) for(int a = b; a <= c; ++ a) typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll; const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+; template<typename T>
inline T read(T&x){
x=;int f=;char ch=getchar();
while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
return x=f?-x:x;
} /**********showtime************/
const int maxn = ;
int p[maxn],a[maxn];
int vis[maxn],used[maxn], ans[maxn];
int que[maxn], dp[maxn];
int n;
int solve() {
int len = ;
for(int i=; i<=n; i++) {
used[i] = ;
if(vis[i]) continue;
int pos = lower_bound(que+, que++len, p[i]) - que;
if(pos > len) {
que[++len] = p[i];
dp[i] = len;
}
else {
que[pos] = p[i];
dp[i] = pos;
}
// for(int i=1; i<=len; i++) cout<<que[i]<<" ";
// cout<<endl;
}
int res = len;
for(int i=n; i>=; i--) {
if(vis[i]) continue;
if(dp[i] == len) {
used[i] = ;
len--;
}
}
return res;
}
int main(){
int T; scanf("%d", &T);
while(T--) {
scanf("%d", &n);
for(int i=; i<=n; i++) scanf("%d", &p[i]);
for(int i=; i<=n; i++) scanf("%d", &a[i]);
for(int i=; i<=n; i++) vis[i] = ; int cur = solve(); for(int i=n; i>=; i--) {
ans[i] = cur;
vis[a[i]] = ;
if(used[a[i]] != ) {
cur = solve();
}
}
for(int i=; i<n; i++) printf("%d ", ans[i]);
printf("%d\n", ans[n]);
}
return ;
}

1011 11 Dimensions

我自己用DP1A了,好像还有康托展开的方法,可以搞搞

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize(4)
#include <algorithm>
#include <iterator>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <cassert>
// #include<bits/extc++.h>
// using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define fi first
#define se second
#define debug(x) cerr<<#x << " := " << x << endl;
#define bug cerr<<"-----------------------"<<endl;
#define FOR(a, b, c) for(int a = b; a <= c; ++ a) typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll; const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+; template<typename T>
inline T read(T&x){
x=;int f=;char ch=getchar();
while (ch<''||ch>'') f|=(ch=='-'),ch=getchar();
while (ch>=''&&ch<='') x=x*+ch-'',ch=getchar();
return x=f?-x:x;
} /**********showtime************/
const int maxn = 5e4+;
ll big = 1e18;
ll dp[maxn][];
ll md[maxn],mdd[maxn];
char str[maxn];
vector<int>vec;
int main(){
md[] = ;
for(int i=; i<maxn; i++) md[i] = md[i-] * % mod;
int T; scanf("%d", &T);
while(T--) {
int n,m,q;
scanf("%d%d%d", &n, &m, &q);
mdd[] = ; for(int i=; i<maxn; i++) mdd[i] = mdd[i-] * % m; scanf("%s", str+);
ll sum = , tp = ;
vec.clear();
for(int i=; i<=n; i++) {
for(int j=; j<m; j++) dp[i][j] = ;
} for(int i=n; i>=; i--) {
if(str[i] == '?') {
if(vec.size() < ) vec.pb(i);
}
else {
sum = (sum + md[n-i] * (str[i] - '') % mod) % mod;
tp = (tp + mdd[n-i] * (str[i] - '') % m) % m;
}
}
dp[][tp] = ; int all = vec.size();
for(int i=; i<=all; i++) {
int id = vec[i-];
for(int j=; j<; j++) {
int up = mdd[n - id] * j % m; for(int k=; k<m; k++) {
ll tmp = dp[i][k] + dp[i - ][(k - up + m) % m];
if(tmp <= big) {
dp[i][k] = tmp;
}
else dp[i][k] = big+;
}
}
} while(q--) {
ll cur = sum;
int flag = ;
int y = ;
ll k; scanf("%lld", &k);
k--;
for(int i=all; i>=; i--) {
int id = vec[i-];
int flag = ;
for(int j=; j<; j++) {
int tmp = (y + j * mdd[n-id] % m) % m;
if(dp[i-][(m - tmp) % m] > k) {
y = tmp;
cur = (cur + j * md[n-id] % mod) % mod;
flag = ;
break;
}
else {
k -= dp[i-][(m - tmp) % m];
}
}
if(flag) {k=; break;}
}
if(k) puts("-1");
else
printf("%lld\n", cur);
}
}
return ;
}

2019DX#6的更多相关文章

  1. 2019DX#10

    Solved Pro.ID Title Ratio(Accepted / Submitted)   1001 Minimum Spanning Trees 22.22%(2/9)   1002 Lin ...

  2. 2019dx#9

    Solved Pro.ID Title Ratio(Accepted / Submitted)   1001 Rikka with Quicksort 25.85%(38/147)   1002 Ri ...

  3. 2019DX#8

    Solved Pro.ID Title Ratio(Accepted / Submitted)   1001 Acesrc and Cube Hypernet 7.32%(3/41)   1002 A ...

  4. 2019dx#7

    Solved Pro.ID Title Ratio(Accepted / Submitted)   1001 A + B = C 10.48%(301/2872)   1002 Bracket Seq ...

  5. 2019DX#5

    Solved Pro.ID Title Ratio(Accepted / Submitted)   1001 fraction 辗转相除 4.17%(7/168) ok  1002 three arr ...

  6. 2019dx#4

    Solved Pro.ID Title Ratio(Accepted / Submitted)   1001 AND Minimum Spanning Tree 31.75%(1018/3206)   ...

  7. 2019DX#3

    Solved Pro.ID Title Ratio(Accepted / Submitted)   1001 Azshara's deep sea 凸包 6.67%(6/90)  

  8. 2019DX#2

    Solved Pro.ID Title Ratio(Accepted / Submitted)   1001 Another Chess Problem 8.33%(1/12)   1002 Beau ...

  9. 2019DX#1

    1001 Blank 题意 有一个长度为n(n<=100)的位子,填入四种颜色,有m个限制,某个区间的颜色个数要恰好等于x个.问颜色个数的方案数. 思路 DP 四维的DP,利用滚动数组优化一维空 ...

随机推荐

  1. “$Bitmap 有标记已使用的未用簇”

    前几天在电脑上用 DiskGenius 给移动硬盘分区的时候出现了这个错误,如下图所示: 解决方法: 在 cmd 命令行窗口中输入如下代码: chkdsk /f /x c: PS: 其中 " ...

  2. [NSNull intValue]: unrecognized selector sent to instance 0x375c9860

    今天遇到这个问题,程序崩溃了……日志如下: -[NSNull intValue]: unrecognized selector sent to instance 0x375c9860*** Termi ...

  3. 对JAVA Bean使用PropertyDescriptor反射调用JAVA方法低耦合

    对于符合JAVA Bean规范的bean,调用其方法应优先使用java.beans.PropertyDescriptor获取Method进行方法调用,以获得更大的可维护性. public void g ...

  4. 后台post注入爆密码

    后台登陆框post注入按照注入的方式属于post,和前台搜索型post注入.文本框注入类似,由于目前主流的注 入工具除了穿山甲等较新工具以外几乎都是get注入,尤其是对于这种后台账户型post注入式无 ...

  5. Linux系统下增加LV(逻辑卷)容量 、Linux系统下减少LV(逻辑卷)容量

    查看文件系统现有lv_test容量,总计4.9G,已使用3% 命令 df -h   查看现有磁盘情况,我们发现磁盘sdb共有1305个柱面,每个柱面大小是8225280 bytes (大约8M).有一 ...

  6. Wtm携手LayUI -- .netcore 开源生态我们是认真的!

    经过WTM团队和LayUI团队多次深入协商,双方于2019年7月29日在北京中国国际展览中心正式达成战略合作意向, 双方签署了战略合作框架协议,LayUI团队承诺使用WTM框架的任何项目都可以免费使用 ...

  7. ajax具体实现学习记录

    记录自己对ajax\的理解, 首先要明白ajax是为了解决什么问题,简单来讲就是为了局部刷新页面,而不刷新整个界面.就比如现在有一个实时热度的显示,它是不断变化的,所以你肯定要不停的从数据库当中获取热 ...

  8. 线性分类 Linear Classification

    软分类:y 的取值只有正负两个离散值,例如 {0, 1} 硬分类:y 是正负两类区间中的连续值,例如 [0, 1] 一.感知机 主要思想:分错的样本数越少越好 用指示函数统计分错的样本数作为损失函数, ...

  9. 使用CefSharp在.NET中嵌入Chromium

    使用CefSharp可以在.NET轻松的嵌入Html,不用担心WPF与Winform 控件与它的兼容性问题,CefSharp大部分的代码是C#,它可以在VB或者其他.NET平台语言中来进行使用. 近几 ...

  10. Gin + Vue全栈开发实战(一)

    Gin入门 本章概要 Gin简介 开发第一个Gin程序 1.1 Gin简介 Gin是用Go语言编写的一个轻量级Web应用框架,现在在各个公司包括字节跳动.bilibili等大互联网公司都得到了广泛的应 ...