hdu 6707 Shuffle Card 模拟

搞个栈模拟就行了

 1 #include <cstdio>
 2 #include <stack>
 3 using namespace std;
 4 stack <int> stk;
 5 int n,m,num[101000];
 6 bool vis[101000];
 7 int main()
 8 {
 9     scanf("%d%d",&n,&m);
10     for (int i = 1;i <= n;i++)
11         scanf("%d",&num[i]);
12     for (int i = n;i >= 1;i--)
13         stk.push(num[i]);
14     int tx;
15     for (int i = 1;i <= m;i++)
16     {
17         scanf("%d",&tx);
18         stk.push(tx); 
19     }
20     while (stk.empty() == false)
21     {
22         if (vis[stk.top()] == false)
23         {
24             printf("%d ",stk.top());
25             vis[stk.top()] = true;
26         }
27         stk.pop();
28     }
29     return 0;
30 }

 

posted @ 2019-08-24 16:02  IAT14  阅读(243)  评论(0编辑  收藏  举报