Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## ABCD前有空格

Posted by ACAccepted at 2019-01-20 16:53:08 on Problem 1094 and last updated at 2019-01-28 14:27:55
```进我的博客浏览：https://www.cnblogs.com/lzxzy-blog/p/10328346.html

#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int MAXN=2500;
int n,m,cas,id;

struct edge
{
int v,nx;
}set[MAXN];
queue<int> Q;

{
}

int bfs()
{
cas=0;
while(!Q.empty())Q.pop();
int out=1,t,u;t=0;
for(int i=1;i<=n;i++)
if(!ok[i])
{
t++;Q.push(i);
}
if(t>1)out=0;
while(!Q.empty())
{
u=Q.front();Q.pop();t=0;write[++cas]=u;
{
ok[set[k].v]--;
if(!ok[set[k].v])
{
t++;Q.push(set[k].v);
}
}
if(t>1)out=0;
}
for(int i=1;i<=n;i++)if(ok[i]>0){out=-1;break;}
return out;
}

char print()
{
for(int i=1;i<=cas;i++)printf("%c",(char)(write[i]+64));
return '.';
}

int main()
{
while(~scanf("%d%d",&n,&m))
{
memset(write,0,sizeof(write));
memset(d,0,sizeof(d));
id=0;
int now=0,loca;
char a,b,c;
if(n==0 && m==0)break;
for(int i=1;i<=m;i++)
{
cin>>a>>b>>c;
if(b=='<')
{
}
else
{
}
if(now==0)
{
for(int j=1;j<=n;j++)ok[j]=d[j];
now=bfs();loca=i;
}
}
if(now==0)puts("Sorted sequence cannot be determined.");
else if(now==1)printf("Sorted sequence determined after %d relations: ",loca),printf("%c\n",print());
else printf("Inconsistency found after %d relations.\n",loca);
}
return 0;
}```

Followed by: