hdu 5071 Chat(模擬|Splay)
Chat
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 571 Accepted Submission(s): 136
Problem Description
As everyone knows, DRD has no girlfriends. But as everyone also knows, DRD’s friend ATM’s friend CLJ has many potential girlfriends. One evidence is CLJ’s chatting record.
CLJ chats with many girls all the time. Sometimes he begins a new conversation and sometimes he ends a conversation. Sometimes he chats with the girl whZ喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vc2Ugd2luZG93IGlzIG9uIHRoZSB0b3AuPGJyPgo8YnI+CllvdSBjYW4gaW1hZ2luZSBDTEqhr3Mgd2luZG93cyBhcyBhIHF1ZXVlLiBUaGUgZmlyc3QgZ2lybCBpbiB0aGUgcXVldWUgaXMgdGhlIHRvcCBnaXJsIGlmIG5vIG9uZSBpcyChsGFsd2F5cyBvbiB0b3AgobEuPGJyPgo8YnI+ClNpbmNlIENMSiBpcyBzbyBwb3B1bGFyLCBoZSBiZWdpbnMgdG8gYXNzaWduIGEgdW5pcXVlIHBvc2l0aXZlIGludGVnZXIgYXMgcHJpb3JpdHkgZm9yIGV2ZXJ5IGdpcmwuIFRoZSBoaWdoZXIgcHJpb3JpdHkgYSBnaXJsIGhhcywgdGhlIG1vcmUgQ0xKIGxpa2VzIGhlci4gRm9yIGV4YW1wbGUsIEdZWiBoYXMgcHJpb3JpdHkgMTA8c3VwPjk8L3N1cD4sIGFuZCBKWlAgaGFzIHByaW9yaXR5IDEwPHN1cD44PC9zdXA+IHdoaWxlIFNpc3RlciBTb3VwIGhhcwogcHJpb3JpdHkgMSwgYW5kIEZhY2UgRmFjZSBoYXMgcHJpb3JpdHkgMi48YnI+Cjxicj4KQXMgYSBmYW1vdXMgcHJvZ3JhbW1lciwgQ0xKIGxlYWRzIGEgZ3JvdXAgdG8gaW1wbGVtZW50IGhpcyBvd24gV00od2luZG93IG1hbmFnZXIpLiBUaGUgV00gd2lsbCBsb2cgQ0xKoa9zIG9wZ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mVyIG9mIHRoZSB0ZXN0IGNhc2VzLjxicj4KPGJyPgpGb3IgZWFjaCB0ZXN0IGNhc2UsIHRoZSBmaXJzdCBsaW5lIGNvbnRhaW5zIGFuIGludGVnZXIgbigwIDwgbiCh3CA1MDAwKSwgcmVwcmVzZW50aW5nIHRoZSBudW1iZXIgb2Ygb3BlcmF0aW9ucy4gVGhlbiBmb2xsb3cgbiBvcGVyYXRpb25zLCBvbmUgaW4gYSBsaW5lLiBBbGwgdGhlIHBhcmFtZXRlcnMgYXJlIHBvc2l0aXZlIGludGVnZXJzIGJlbG93IDEwPHN1cD45PC9zdXA+LgogCjxicj4KT3V0cHV0Ck91dHB1dCBhbGwgdGhlIGxvZ2dpbmcgY29udGVudHMuCiAKPGJyPgpTYW1wbGUgSW5wdXQKCjxwcmUgY2xhc3M9"brush:java;">1
18
Prior
Add 1
Chat 1
Add 2
Chat 2
Top 2
Chat 3
Untop
Chat 4
Choose 2
Chat 5
Rotate 2
Chat 4
Close 2
Add 3
Prior
Chat 2
Close 1
Sample Output
Operation #1: empty.
Operation #2: success.
Operation #3: success.
Operation #4: success.
Operation #5: success.
Operation #6: success.
Operation #7: success.
Operation #8: success.
Operation #9: success.
Operation #10: success.
Operation #11: success.
Operation #12: success.
Operation #13: success.
Operation #14: close 2 with 8.
Operation #15: success.
Operation #16: success.
Operation #17: success.
Operation #18: close 1 with 11.
Bye 3: 2
HintThis problem description does not relate to any real person in THU.
Source
2014 Asia AnShan Regional Contest
Recommend
liuyiding | We have carefully selected several similar problems for you: 5081 5080 5079 5078 5077
題意:
就是要你寫一個聊天窗口管理系統。支持增加窗口。關閉窗口。管理優先級。。。。。詳細的還是自己讀吧。
思路:
覺得splay可做就用splay做的。功能也是splay最基本的功能。這題需要注意的是。最後Bye的時候是先給置頂的人然後按隊列順序Bye。
詳細見代碼:
#include
#include
#include
#include
#include