#include<iostream>#include<cstring>#include<queue>#include<vector>#include<cmath>#include<iomanip>using namespace std;//本题容易出错的地方:是在17:00及以后开始服务的客户输出"Sorry",而不是17:00之前结束服务的输出"Sorry";//如客户cId是16:59开始服务,服务时间为2,则输出的应该是17:01,而不是"Sorry"。co Read More
#include<iostream>#include<cstring>#include<queue>#include<vector>#include<cmath>#include<iomanip>using namespace std;struct Node{ int exp; double coe;};vector<Node> vRes;//将两个多项式相加,最后的结果保存在v1中。//即将两个有序链表merge在一起。void addPols(vector<Node> &v1,vecto Read More
#include<iostream>#include<cstring>#include<queue>using namespace std;int main(){ char str[100]; int len,n1,n2; cin>>str; len = strlen(str); //先求出n1和n2 if( (len-1)%2 == 0 ) { n1 = (len-1)/2; n2 = 3; } else { n1 = (len-2)/2; n2 = 4; } wh... Read More
#include<iostream>#include<cstring>#include<queue>using namespace std;//已知二叉树的后序和中序遍历,得到层次遍历顺序。const int N = 30;struct Node{ Node* left; Node* right; int data;};int postOrder[N];int inOrder[N];//b1,e1表示后序的开始和结束位置;b2,e2表示中序的开始和结束位置。void createTree(int b1,int e1,int b2,int e2,Node* & Read More
#include<iostream>#include<cstring>using namespace std;const int N = 1000;const int INF = 100000000;//图的邻接矩阵int road[N][N];//标记某一节点是否被访问过bool isVisited[N];//记录每一节点的权值int team_num[N];int dis[N];//最短路径的数目int path_num =0;//最大的医疗队的数目int g_max_team_num = 0;void initData(){ int i,j; for(i=0; i Read More
#include<iostream>#include<cstring>using namespace std;const int N = 1000;const int INF = 100000000;//图的邻接矩阵int road[N][N];//标记某一节点是否被访问过bool isVisited[N];//记录每一节点的权值int team_num[N];int dis[N];//最短路径的数目int path_num =0;//最大的医疗队的数目int g_max_team_num = 0;void initData(){ int i,j; for(i=0; i Read More
#include<iostream>#include<cstring>using namespace std;int main(){ char stu_in[15],stu_out[15],stu[15]; char sign_in[10] = "23:59:59"; char sign_out[10] = "00:00:00"; char tmp_in[10],tmp_out[10]; int num,i; cin>>num; for(i=0; i<num; i++) { cin>>stu>& Read More
#include<iostream>using namespace std;const int INF_MIN = 0x80000000;bool isAllNeg(int a[], int n){ int i = 0; for(i=0; i<n; i++) if(a[i] >= 0) return false; return true;}int findMaxSubSeq(int a[],int n,int &b,int &e){ int max = INF_MIN; int i = 0; int t1 = a[0]; int t2 = a[0]; i Read More
#include<iostream>#include<vector>#include<queue>using namespace std;int main(){ int n,m,par_id,k,child_id,par[101],i,j; vector<int> v; queue<int> Q,Q_tmp; cin>>n>>m; for(i=1; i<=n; i++) par[i] = i; for(i=0; i<m; i++) { cin>>par_id; cin>>k; Read More
#include<iostream>#include<cstring>#include<cstdio>using namespace std;const int SIZE = 5000;int g_preOrder[SIZE];int g_preOrderImg[SIZE];int g_postOrder[SIZE];int g_index = 0;struct BSNode{ BSNode *left; BSNode *right; int key;};//在一颗二叉查找树中添加一个节点。isImg为true,则表示生成的//是二叉查找树的镜像;void Read More