POJ2259-Team Queue
来源:互联网 发布:windows 鼠标样式 编辑:程序博客网 时间:2024/05/29 11:02
以前在uva上做过这个题,一模一样的,但是这次还是弄了个RE,而且这次的错误与上次完全不同;
以前的错误是逻辑错误,这次的而代码错误,只是少个else。
用了一晚上的时间,用神一样的测试数据终于揪出了这个错误。
错误见代码《
测试数据见UVA540.
#include <iostream>#include <cstdlib>#include <string>#include <cstring>using namespace std;struct node{ int data; node *next;};struct zu{ int count; node *tail, *head;};int cla[1000050];zu z[1050];node* head = NULL, *tail = NULL;void input(int t){ int n, temp; for(int i = 1; i <= t; i++) { cin>>n; while(n--) { cin>>temp; cla[temp] = i; } }}void enqueue(){ int temp; cin>>temp; node *q = (node*)malloc(sizeof(node)); q->data = temp; q->next = NULL; if(!head) { head = tail = q; z[cla[temp]].count = 1; z[cla[temp]].head = z[cla[temp]].tail = q; } else if(!z[cla[temp]].count)//千呼万唤始出来的错误,此处少了个else,也算的上是逻辑漏洞,以为我的愿意是正确的,-_-#! { z[cla[temp]].count = 1; z[cla[temp]].head = z[cla[temp]].tail = q; tail->next = q; tail = q; } else { z[cla[temp]].count++; q->next = z[cla[temp]].tail->next; z[cla[temp]].tail->next = q; z[cla[temp]].tail = q; if(tail->next == q)tail = q; }}void dequeue(){ node *q = head; q = head; z[cla[q->data]].count--; z[cla[q->data]].head = z[cla[q->data]].head->next; cout<<q->data<<endl; head = head->next; delete q;}int main (){ int t, num = 0; string s; while(cin>>t&&t) { head = tail = NULL; memset(z,0,sizeof(z)); input(t); cout<<"Scenario #"<<++num<<endl; while(cin>>s) { cin.ignore(); if(s == "ENQUEUE")enqueue(); if(s == "DEQUEUE")dequeue(); if(s == "STOP") break; } cout<<endl; } return 0;}
- poj2259 Team Queue (队列)
- POJ2259-Team Queue
- 【队列】POJ2259-Team Queue-【容易题】
- 【STL】poj2259 Team Queue (队列+map的应用)
- Queue Team
- Team Queue
- Team Queue
- Team Queue
- Team Queue
- UVa540 Team Queue (queue)
- Team Queue(queue) - uva 540
- ZOJ 1948 Team Queue
- UVa 540 Team Queue
- uva540 team queue
- uva 540 team queue
- 540 - Team Queue***
- Uva 540 Team Queue
- uva 540 - Team Queue
- Kinect for Java
- To Be an Dream Architect(2010年ACM亚洲预选赛杭州赛区第三题))
- javac -d 和-classpath 用法 .
- https://github.com/enormego/cocoa-helpers
- 用python实现网络爬虫
- POJ2259-Team Queue
- adb push时提示read-only file system
- C#获取路径方法
- oracle数据库PL/SQL之包
- windows消息大全
- 小实验 oracle view
- 栈溢出
- asp.net中的事件原理
- 黑马程序员之C#学习笔记:面向对象小结