Przechodzi test przykładowy i testy, które sam zrobiłem, ale nadal WA 
[bbone=cpp,830]//Jakub Stanecki XIV LO w Warszawie
include
include
include
include
using namespace std;
typedef vector VI;
define FOR(x, b, e) for(int x = b; x <= (e); ++x)
define FORD(x, b, e) for(int x = b; x >= (e); --x)
define REP(x, n) for(int x = 0; x < (n); ++x)
define VAR(v, n) __typeof(n) v = (n)
define ALL(c) (c).begin(), (c).end()
define SIZE(x) ((int)(x).size())
define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
define PB push_back
define ST first
define ND second
define PF push_front
define MP make_pair
char tab[100000];
struct wezel
{
string name;
bool created;
vector > atr;
VI sons;
int father;
};
inline bool saspacje(string a)
{
REP(x,SIZE(a))
{
if (a[x]==' ')
{
return true;
}
}
return false;
}
inline bool typ1(string a)
{
if (a[0]=='<' && a[SIZE(a)-1]=='>' && a[SIZE(a)-2]!='/' && a[1]!='/' && !saspacje(a)) return true;
return false;
}
inline bool typ2(string a)
{
if (a[0]=='<' && a[SIZE(a)-1]=='>' && a[SIZE(a)-2]!='/' && a[1]!='/' && saspacje(a)) return true;
return false;
}
inline bool typ3(string a)
{
if (a[0]=='<' && a[SIZE(a)-1]=='>' && a[SIZE(a)-2]=='/' && a[1]!='/' && !saspacje(a)) return true;
return false;
}
inline bool typ4(string a)
{
if (a[0]=='<' && a[SIZE(a)-1]=='>' && a[SIZE(a)-2]=='/' && a[1]!='/' && saspacje(a)) return true;
return false;
}
inline bool typ5(string a)
{
if (a[0]=='<' && a[SIZE(a)-1]=='>' && a[SIZE(a)-2]!='/' && a[1]=='/' && !saspacje(a)) return true;
return false;
}
inline int findfirstspace(string a)
{
REP(x,SIZE(a)) if(a[x]==' ') return x;
}
inline int findrownasie(string a)
{
REP(x,SIZE(a)) if (a[x]=='=') return x;
}
vector drz;
void show(int z, int level)
{
if (z==0)
{
FOREACH(i,drz[z].sons)
{
show(*i,0);
}
}
else
{
if (drz[z].name.empty()) return;
REP(x,level*4) printf(" ");
printf("%s:\n",drz[z].name.c_str());
FOREACH(i,drz[z].atr)
{
REP(x,(level+1)*4)
{
printf(" ");
}
printf("%s = %s\n",(i->ST).c_str(),(i->ND).c_str());
}
FOREACH(i,drz[z].sons)
{
show(*i,level+1);
}
}
}
int main()
{
wezel nic;
drz.PB(nic);
drz.PB(nic);
drz[0].sons.PB(1);
int t=1;
int pt=0;
int p=0;
char c;
while(scanf("%c",&c)!=EOF)
{
if (c=='\n')
{
string cos;
int ile=0;
REP(x,p)
{
if (tab[x]=='<') ile++;
if (tab[x]=='>') ile++;
if ((tab[x]==' ' && tab[x-1]=='>') || x==p-1 || ile==2)
{
if (SIZE(cos)>1)
{
if (x==p-1 || tab[x]=='>' || tab[x]=='<') cos+=tab[x];
if (typ1(cos))
{
wezel edek;
string name="";
FOR(y,1,SIZE(cos)-2)
{
name+=cos[y];
}
edek.name=name;
edek.created=1;
edek.father=pt;
drz.PB(nic);
edek.sons.PB(SIZE(drz)-1);
drz[t]=edek;
pt=t;
t=SIZE(drz)-1;
}
else if (typ2(cos))
{
int pos=findfirstspace(cos);
wezel edek;
string name="";
FOR(y,1,pos-1)
{
name+=cos[y];
}
edek.created=1;
edek.name=name;
if (pos!=SIZE(cos)-2)
{
string parse="";
FOR(y,pos+1,SIZE(cos)-2)
{
parse+=cos[y];
}
string pom="";
REP(y,SIZE(parse))
{
if ((parse[y]==' ' && y!=SIZE(parse)-1) || (y==SIZE(parse)-1))
{
int ppo=findrownasie(pom);
string wh="";
REP(z,ppo)
{
wh+=pom[z];
}
string na="";
FOR(z,ppo+2,SIZE(pom)-1)
{
if (pom[z]!='"')na+=pom[z];
}
edek.atr.PB(MP(wh,na));
pom="";
}
else
{
pom+=parse[y];
}
}
}
drz.PB(nic);
edek.father=pt;
edek.sons.PB(SIZE(drz)-1);
drz[t]=edek;
pt=t;
t=SIZE(drz)-1;
}
else if (typ3(cos))
{
wezel edek;
string name="";
FOR(y,1,SIZE(cos)-3)
{
name+=cos[y];
}
edek.name=name;
edek.father=pt;
edek.created=1;
drz[t]=edek;
t=pt;
drz.PB(nic);
drz[t].sons.PB(SIZE(drz)-1);
pt=t;
t=SIZE(drz)-1;
}
else if (typ4(cos))
{
int pos=findfirstspace(cos);
wezel edek;
string name="";
FOR(y,1,pos-1)
{
name+=cos[y];
}
edek.name=name;
edek.created=1;
if (pos!=SIZE(cos)-3)
{
string parse="";
FOR(y,pos+1,SIZE(cos)-3)
{
parse+=cos[y];
}
string pom="";
REP(y,SIZE(parse))
{
if ((parse[y]==' ' && y!=SIZE(parse)-1) || (y==SIZE(parse)-1))
{
int ppo=findrownasie(pom);
string wh="";
REP(z,ppo)
{
wh+=pom[z];
}
string na="";
FOR(z,ppo+2,SIZE(pom)-1)
{
if (pom[z]!='"')na+=pom[z];
}
pom="";
}
else
{
pom+=parse[y];
}
}
}
edek.created=1;
drz[t]=edek;
t=pt;
drz.PB(nic);
drz[t].sons.PB(SIZE(drz)-1);
pt=t;
t=SIZE(drz)-1;
}
else if (typ5(cos))
{
t=pt;
t=drz[t].father;
drz.PB(nic);
drz[t].sons.PB(SIZE(drz)-1);
pt=t;
t=SIZE(drz)-1;
}
}
cos="";
ile=0;
}
else
{
cos+=tab[x];
}
}
p=0;
}
else
{
tab[p++]=c;
}
}
show(0,0);
return 0;
}
[/bbone]