[2019鏉數澶氭牎绗叚鍦篯[hdu6635]Nonsense Time

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[2019鏉數澶氭牎绗叚鍦篯[hdu6635]Nonsense Time相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/targe' title='targe'>targe   for   can   lse   mes   using   include   algorithm   pre   

棰樼洰閾炬帴锛?a href="http://acm.hdu.edu.cn/showproblem.php?pid=6635" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=6635

棰樻剰鏄涓€寮€濮嬫墍鏈夋暟閮藉喕缁擄紝绗琲绉掍細瑙e喕绗琸i涓暟锛屾眰姣忕鐘舵€佷笅鐨勬渶闀夸笂涓婂崌瀛愬簭鍒楅暱搴︺€?/p>

杩欑棰樹竴鎯虫坊鍔犳搷浣滃氨涓嶅ソ瀹炵幇锛屾墍浠ュ共鑴嗗弽鐫€鏉ワ紝鎯冲垹闄ゆ搷浣溿€?/p>

浠庣n绉掑紑濮嬪線鍓嶉亶鍘嗭紝姣忔閮戒細鍐荤粨涓€涓暟锛岃繖鏃跺垽鏂竴涓嬭繖涓暟鏄惁涓€瀹氳鍦ㄦ渶闀夸笂鍗囧瓙搴忓垪閲屻€?/p>

浣跨敤浜屽垎鐨勬柟娉曟眰鏈€闀夸笂鍗囧瓙搴忓垪锛屽苟涓旀瘡娆℃眰瀹屽瓙搴忓垪鍚庡彲浠ュ鐞嗗嚭閭d簺浣嶇疆鏄繀椤诲湪鏈€闀夸笂鍗囧瓙搴忓垪閲岀殑銆?/p>

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<string>
 5 #include<algorithm>
 6 #include<queue>
 7 using namespace std;
 8 const int maxn = 5e4 + 10;
 9 int a[maxn], vis[maxn], ans[maxn], d[maxn], in[maxn], dp[maxn];
10 int len;
11 void  slove(int n) 
12     len = 0;
13     for (int i = 1; i <= n; i++) 
14         if (a[i] != 0) 
15             int pos = lower_bound(d + 1, d + 1 + len, a[i]) - d;
16             if (pos > len)
17                 d[++len] = a[i];
18             else
19                 d[pos] = a[i];
20             dp[i] = pos;
21         
22     
23     int q = len, limit = n;
24     for (int i = n; i >= 1; i--) 
25         if (dp[i] == q && a[i] <= limit && a[i] != 0) 
26             limit = a[i];
27             in[i] = 1;
28             q--;
29         
30         else
31             in[i] = 0;
32     
33 
34 int main() 
35     int t;
36     scanf("%d", &t);
37     while (t--) 
38         int n;
39         scanf("%d", &n);
40         for (int i = 1; i <= n; i++)
41             scanf("%d", &a[i]);
42         for (int i = 1; i <= n; i++)
43             scanf("%d", &vis[i]);
44         slove(n);
45         for (int i = n; i >= 1; i--) 
46             ans[i] = len;
47             a[vis[i]] = 0;
48             if (in[vis[i]])slove(n);
49         
50         for (int i = 1; i <= n; i++)
51             printf("%d%c", ans[i], i == n ? 鈥?/span>\n鈥?/span> : 鈥?/span> 鈥?/span>);
52     
53 

 

以上是关于[2019鏉數澶氭牎绗叚鍦篯[hdu6635]Nonsense Time的主要内容,如果未能解决你的问题,请参考以下文章

娴呰皥瀛樺偍杩囩▼

HDU 2072 单词数

澶氭€佷笌閲嶈浇

Beautiful Now 鏉數绗簲鍦?鏆村姏鏋氫妇

UE4 鍒濆鏉愯川Fresnel鑺傜偣

澶氭€佷腑鐨勯鐩垎鏋愰