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. Python装饰器实现类Java注解功能

    最近想用Python写一个简单生成器,类似指定类型和范围,返回指定列表: 比如想要  0 ~ 3 的整数,则 我只需要指定: 最小:0, 最大:3, 步长:1 则返回一个 [0,1,2,3] 的列表 ...

  2. Python装饰器 (转)

    多个装饰器执行的顺序就是从最后一个装饰器开始,执行到第一个装饰器,再执行函数本身. #多个装饰器 import time def deco01(func): def wrapper(*args, ** ...

  3. wangEditor富文本编辑器使用及图片上传

    引入js文件 <script type="text/javascript" src="style/js/wangEditor.min.js">< ...

  4. WPF滑块控件(Slider)的自定义样式

    前言 每次开发滑块控件的样式都要花很久去读样式代码,感觉有点记不牢,所以特此备忘. 自定义滑块样式 首先创建项目,添加Slider控件. 然后获取Slider的Window样式,如下图操作. 然后弹出 ...

  5. wscript.shell 使用

    <%@ Page Language="VB" validateRequest = "false" aspcompat = "true" ...

  6. 2019中山纪念中学夏令营-Day9[JZOJ](第六次模拟赛)

    Begin (题目的排序方式:Unkown其实是按心情排的) 异或:(摘自百度百科) 异或(xor)是一个数学运算符.它应用于逻辑运算.异或的数学符号为“⊕”,计算机符号为“xor”.其运算法则为: ...

  7. Flink+Druid构建实时OLAP的探索

    场景 k12在线教育公司的业务场景中,有一些业务场景需要实时统计和分析,如分析在线上课老师数量.学生数量,实时销售额,课堂崩溃率等,需要实时反应上课的质量问题,以便于对整个公司的业务情况有大致的了解. ...

  8. 建立第一个G2图表

    Step1:引进G2脚本 方法一:引入在线脚本 <script src="https://gw.alipayobjects.com/os/lib/antv/g2/3.4.10/dist ...

  9. springboot整合websocket原生版

    目录 HTTP缺点 HTTP websocket区别 websocket原理 使用场景 springboot整合websocket 环境准备 客户端连接 加入战队 微信公众号 主题 HTTP请求用于我 ...

  10. 洛谷 P2152 [SDOI2009]SuperGCD

    题意简述 求两个整数a,b的最大公约数0 < a , b ≤ 10 ^ 10000. 题解思路 如果 a % 2 == 0 && b % 2 == 0 gcd(a,b) = gc ...