#include
#include
#include
#define maxn 1000
int main()
{
int n[maxn];
int i=0;
int j=0;
int ii=0;
int m;
int k;
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
scanf("%d",&i);
for (ii=0;ii0;ii--)
{
for(k=0;kn[k+1])
{
j=n[k];
n[k]=n[k+1];
n[k+1]=j;
}
}
for(m=0;m
#include
#include
#include
#define maxn 1000
#define true 1
#define false 0
int Isword(char c);
int END(char c);
int check(char word[]);
int num;
char name[1000][20];
int main()
{
int xx;
char word[20];
int n=0,i=0,ii;
int flag=true;
char c;
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
while((c=getchar())!=EOF)
{
if(c==' ') break;
}
while((c=getchar())!=EOF)
{
if(END(c)&&i!=0)
{
name[n][i]='\0';
n++;
i=0;
flag=false;
}
if(c==';'){
name[n][i]='\0';
break;
}
if(flag && Isword(c))name[n][i++]=c;
flag=true;
}
//for(ii=0;ii='a'&&c<='z')||(c>='A'&&c<='Z')||(c>='0'&&c<='9')||c=='_') return 1;
return 0;
}
int END(char c)
{
if(c=='='||c=='+'||c=='-'||c=='*'||c=='/'||c=='%'||c==';'||c==','||c=='['||c==']'||c==' ') return true;
return false;
}
int check(char word[])
{
int i=0;
for(;i
#include
#include
#include
#define maxn 1000
struct node{
char name[20];
int lchild;
int rchild;
int layer;
}Node[maxn];
int dfs(int n,char s[])
{
int l,r;
if(strcmp(Node[n].name,s)==0) return n;
if(Node[n].lchild==0) return -1;
l=dfs(Node[n].lchild,s);
r=dfs(Node[n].rchild,s);
return (l>r)?l:r;
}
int find(char s[])
{
return dfs(1,s);
}
int main()
{
char m[3][20];
int n=1;
int i,ii,father=0;
int flag=0;
int layer1,layer2;
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
while(scanf("%s %s %s",m[0],m[1],m[2])==3)
{
if(flag){
int top=find(m[0]);
printf("top=%d \n",top);
Node[top].lchild=++n;
strcpy(Node[n].name,m[1]);
Node[top].rchild=++n;
strcpy(Node[n].name,m[2]);
Node[Node[top].lchild].layer=Node[top].layer+1;
Node[Node[top].rchild].layer=Node[top].layer+1;
}else{
int top=n;
Node[top].layer=1;
strcpy(Node[top].name,m[0]);
Node[top].lchild=++n;
strcpy(Node[n].name,m[1]);
Node[top].rchild=++n;
strcpy(Node[n].name,m[2]);
Node[Node[top].lchild].layer=Node[top].layer+1;
Node[Node[top].rchild].layer=Node[top].layer+1;
}
flag=1;
}
for(ii=1;ii
#include
#include
#include
#include
#define maxn 1000
int root[maxn]={0};
int father[maxn]={0};
int k=0;
struct course{
int id[maxn];
int num;
}c[maxn];
int findfather(int n)
{
if(n==father[n])
return n;
else return findfather(father[n]);
}
void Union(int id1,int id2)
{
int nn,mm;
nn=findfather(id1);
mm=findfather(id2);
father[nn]=mm;
}
int course[maxn][maxn];
int n;
int main()
{
int m,id=0,test=0,max=0;
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
scanf("%d",&n);
for(m=0;mc_id?max:c_id;
c[c_id].id[c[c_id].num++]=m;
}
}
for(m=0;m
#include
#include
#include
#include
#include
#include
#define INF 1000000000
#include
#define maxn 100
using namespace std;
#pragma warning(disable : 4786)
set Pre[maxn];
struct node{
int v;
int dis;
};
vector Node[maxn];
int n,st,m;
int num[maxn]; int dis[maxn];
void Bellman(int s)
{
fill(dis,dis+maxn,INF);
//fill (dis,dis+maxn,INF);
memset(num,0,sizeof(num));
dis[s]=0;
for(int v=0;v:: iterator it=Pre[n_node].begin();it!=Pre[n_node].end();it++){
num[n_node]+=num[*it];
}
}
}
}
}
}
int main()
{
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
node Point;
scanf("%d %d %d",&n,&m,&st);
for(int i=0;i :: iterator it=Pre[i].begin();it!=Pre[i].end();it++)
{
printf("%d ",*it);
}
printf("\n");
}
}
#include
#include
#include
#define maxn 100
#define INF 100000000
using namespace std;
//int G[maxn][maxn];
int dis[maxn][maxn];
int n,m;
int main()
{
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
//fill(G[0],G[0]+maxn*maxn,INF);
fill(dis[0],dis[0]+maxn*maxn,INF);
scanf("%d %d",&n,&m);
for(int i=0;i
#include
#include
#include
#include
#define maxn 1000
#define INF 100000000
using namespace std;
//int G[maxn][maxn];
int G[maxn][maxn];
int dis[maxn];
bool vis[maxn]={false};
setPre[maxn];
int n,m,st;
void Prim(int s)
{
fill(dis,dis+maxn,INF);
dis[s]=0;
for(int i=0;i
void getNext (char c[] ,len)
{
int j=-1;
next[0]=-1
for(int i=1;i
#include
#include
#include
#include
using namespace std;
#define maxn 1000
int dis[maxn][maxn];
string str;
int n;
int MAX;
int ll,rr;
int main()
{
getline(cin,str);
memset(dis,0,sizeof(dis));
int n=str.length();
for(int i=0;iMAX)
{
MAX=L;
ll=i;
rr=i+L-1;
}
}
}
}
for(i=ll;i<=rr;i++)
{
cout<