是清華的ACM試題吧,我剛做完,你試試看.
#include
using std::cout;
using std::cin;
using std::endl;
struct item{
char key;
int priority;
struct item** smaller;
struct item** greater;
};
typedef struct item Item;
int placeToAdd(Item** a,char b,int n){
int i;
for(i=0;ikey)==b) return i;
else if((a[i]->key)==' ') {
a[i]->key=b;
return i;
}
}
if(i>=n) return -1;
}
int hasCompared(Item** a,int i,int j,int n){
int m=0;
if(i==j)return -1;
while((((a[i]->greater[m])!=0||a[i]->smaller[m])!=0)&&mgreater[m])==a[j]) return 1;
else if((a[i]->smaller[m])==a[j]) return -1;
m++;
}
if(mgreater[m]=a[j];
m=0;
while((a[j]->smaller[m])!=0&&mpriority>=a[j]->priority) a[j]->priority=a[i]->priority+1;
int k=0;
while((a[j]->greater[k])!=0&&kgreater[k]->priority+=1;
k++;
}
return 0;
}
}
int main(){
int l,m,n,i,j;
int unsorted=0,inconsistent=0;
char sign,first,second;
cin>>m>>n;
if(m==0||n==0){
coutgreater[j]=0;
}
}
l=n;
while(n>0){
cin>>first>>sign>>second;
i=placeToAdd(a,first,m);
j=placeToAdd(a,second,m);
if(i!=-1&&j!=-1){
if(keySetting(i,j,a,m)==-1) inconsistent=1;
}
else unsorted=1;
n--;
}
if(unsorted) cout
英語翻譯
英語翻譯
An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest.For example,the sorted sequence A,B,C,D implies that A < B,B < C and C < D.in this problem,we will give you a set of relations of the form A < B and ask you to determine whether a sorted order has been specified or not.
Input
Input consists of multiple problem instances.Each instance starts with a line containing two positive integers n and m.the first value indicated the number of objects to sort,where 2
An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to largest.For example,the sorted sequence A,B,C,D implies that A < B,B < C and C < D.in this problem,we will give you a set of relations of the form A < B and ask you to determine whether a sorted order has been specified or not.
Input
Input consists of multiple problem instances.Each instance starts with a line containing two positive integers n and m.the first value indicated the number of objects to sort,where 2
其他人氣:975 ℃時間:2019-09-17 09:50:30
優(yōu)質解答
我來回答
類似推薦
- 英語翻譯
- 英語翻譯
- 右圖中空白部分的面積比陰影部分大24平方米,求陰影部分的面積
- 不需要反映條件
- 小學英語每單元課可以分為哪幾類
- 作文《生活因母愛而精彩》400-500字
- 閱讀理解《諾貝爾文學情結》答案
- 一個梯形的下底是上底的三倍,如果將上底延長六厘米,就成一個平行四邊形,這個梯形的上底和下底是多少厘
- 月末企業(yè)銀行存款日記賬余額為180000元,銀行對賬單余額為170000元,經過未達帳項調節(jié)后的余額為160000元,則對賬日企業(yè)可以動用的銀行存款實有數額為多少元?
- It has three floors ___ five bedrooms a.with b.for c.under d.of
- It's a find day _______a walk.Let's go to the park.A.to B.of C.for D.at
- He failed to pass the text last week.(句意不變)
猜你喜歡
- 1同桌抄我作業(yè)
- 2把一根木料鋸成相等的7段,每段所用的時間占鋸這根木料總時間的幾分之幾?
- 3水浴加熱 當燒杯內的水到100℃后試管中的水為什么不沸騰?
- 4小麗捐出了零用錢的一半多20元,這是還剩下100元,小麗求原有多少元
- 5(2X減三)平方等于根二(2X減三)的解題過程
- 6若某原子的摩爾質量是M g/mol,則一個該原子的真實質量約是多少?
- 71、下面___是合法的字符型常量.A.ABC$ B.“ABD”C.ABC D.ABC’
- 81比2比根號5的直角三角形,其他兩個角是多少度?
- 996-3.56-6.44 (簡便計算)
- 10翻譯The disease affected his mind so that he lost his memory.
- 11Cu與石墨做電極,HCl做電解質,能形成原電池嗎
- 12X1,X2是方程x^2-(2m-1)x+(m^2+2m-4)=0的兩個實數根,求x1^2+x2^2的最小值