hdu 5071

Posted 十目

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 5071相关的知识,希望对你有一定的参考价值。

题意:  大模拟

题解:每次把always top标记的人关掉要把标记也去掉,聊天数用long long,最后先和有标记的人说拜拜

#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
#define PF(x) cout << "debug: " << x << " ";
#define EL cout << endl;
#define PC(x) puts(x);
typedef long long ll;
#define CLR(x, v) sizeof (x, v, sizeof(x))
using namespace std;
const int INF = 0x5f5f5f5f;
const int  N= 2e5 + 10;
const int mod=1e9 + 7;
const int maxn = 5e3 + 10;
int n,t,topfg,stk[maxn],cnt;//num shuohua  shuliang,fg  shifou  zai duilie
map<int,ll>fg,num;
int main()
{
  // freopen("in.txt","r",stdin);
    cin>>t;
    int cas = 0;
    while(t--){
        fg.clear();
        num.clear();
        topfg = 0;
        cnt = 0;
        cas = 0;
        scanf("%d",&n);
        char ss[20];
        while(n--){
            cas++;
            printf("Operation #%d: ",cas);
            getchar();
            scanf("%s",ss);
           // cout<<ss<<endl;
            if(ss[0]==A){
                int u;
                scanf("%d",&u);
               if(fg[u] > 0) printf("same priority.\n");
                else{
                    stk[++cnt] = u;
                    fg[u] = 1;
                    printf("success.\n");
                }
            }
            else if(ss[0] == R){
                int u;
                scanf("%d",&u);
                if(u < 1||u > cnt)
                    printf("out of range.\n");
                else{
                    int x = stk[u];
                    for(int i = u;i >= 2;i--)
                        stk[i] = stk[i - 1];
                    stk[1] = x;
                    printf("success.\n");
                }
            }
            else if(ss[0] == P){
                if(cnt == 0) printf("empty.\n");
                else{
                    int pos;
                    int pir = 0;
                    for(int i = 1;i <= cnt;i++){
                        if(pir < stk[i]){
                            pos = i;
                            pir = stk[i];
                        }
                    }
                    for(int i = pos;i >= 2;i--)
                        stk[i] = stk[i - 1];
                    stk[1] = pir;
                    printf("success.\n");
                }
            }
            else if(ss[0] == T){
                int u;
                scanf("%d",&u);
                if(!fg[u])  printf("invalid priority.\n");
                else{
                    topfg = u;
                    printf("success.\n");
                }
            }
            else if(ss[0] == U){
                if(topfg == 0) printf("no such person.\n");
                else {
                topfg = 0;
                printf("success.\n");
            }
            }
            else if(ss[0] == C){
                if(ss[1] == l){
                    int u;
                    scanf("%d",&u);
                    if(!fg[u])  printf("invalid priority.\n");
                    else{
                        printf("close %d with %lld.\n",u,num[u]);
                        if(topfg == u) topfg = 0;
                        num[u] = 0,fg[u] = 0;
                        
                        int pos = 0;
                        for(int i = 1;i <= cnt;i++){
                            if(stk[i] == u){
                                pos = 1;
                                continue;
                            }
                            if(pos)
                                stk[i - 1] = stk[i];
                        }
                        cnt--;
                       // printf("success.\n");
                    }

                }
                if(ss[1] == h){
                    if(ss[2] == a){
                    int w;
                    scanf("%d",&w);
                    if(cnt == 0) printf("empty.\n");
                    else{
                        if(topfg > 0 && fg[topfg] > 0) num[topfg] += w;
                        else num[stk[1]] += w;
                        printf("success.\n");
                    }
                }
                    if(ss[2] == o){
                        int u;
                        scanf("%d",&u);
                        if(!fg[u]) printf("invalid priority.\n");
                        else{
                            int pos;
                            int pir = u;
                            for(int i = 1;i <= cnt;i++){
                                if(u == stk[i]){
                                    pos = i;
                                    break;
                        }
                    }
                            for(int i = pos;i >= 2;i--)
                                stk[i] = stk[i - 1];
                            stk[1] = pir;
                            printf("success.\n");

                        }

                    }

               }
            }

        }
       if(fg[topfg] > 0&& num[topfg] > 0)  printf("Bye %d: %lld\n",topfg,num[topfg]);
       num[topfg] = 0;
        for(int i = 1;i <= cnt;i++)
            if(num[stk[i]] > 0&&fg[stk[i]] > 0)
                printf("Bye %d: %lld\n",stk[i],num[stk[i]]);

    }

    return 0;
}

 

以上是关于hdu 5071的主要内容,如果未能解决你的问题,请参考以下文章

HDU - 5071 Chat(模拟)

[BZOJ 5071]小A的数字

BZOJ5071[Lydsy十月月赛]小A的数字 发现性质

ZJ选讲·BZOJ 5071

[BZOJ 5071]小A的数字

英伟达网卡驱动下载 nvidia mcp-78 - lan controller (phy:broadcom b5071)在那下载这个网卡驱动啊?