### Saratov State University :: Online Contester

::Go
- home
- news
- register
 - update personal info
 - problemset archive
- submit
- status online
- standing
- contests
- virtual contests
- forum
- statistic
- FAQ
- projects

 ::Poll Are you registered on Codeforces?YesNoWhat is it???[results]

::webboard

 Can anyone tell me what's wrong with my program?(Thanks)
Author: crystal_yi
ID: 049657
Problem: 101
Contest: 0
Date: 2011-12-18 09:24:31

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define le 205
#define lne 8

typedef struct {
int u , v , nxt , id , state;
}re;
re e[le];

int g[lne] , vis[le] , path[le] , map[lne][lne] , copy[lne][lne];

int k , m;

void init (){
k = 0 ;
memset ( g , -1 , sizeof ( g ) );
memset ( copy , 0 , sizeof ( copy ) );
}

void addedge ( int u , int v , int id , int state ){
e[k].u = u;
e[k].v = v;
e[k].id = id;
e[k].state = state;
e[k].nxt = g[u]; g[u] = k++;
}

void input (){
int i , u , v;
init ();
for ( i = 1 ; i <= m ; i++ ){
scanf ( "%d%d" , &u , &v );
addedge ( u , v , i , 0 );
addedge ( v , u , i , 1 );
copy[u][v]++;
copy[v][u]++;
}
}

int dfs ( int u , int dep ){
int v , i , j;
if ( dep >= m ) return 1;
for ( i = g[u] ; ~i ; i = e[i].nxt ){
v = e[i].v;
j = e[i].id;
if ( map[u][v] && !vis[j] ){
map[u][v]-- , map[v][u]--;
vis[j] = 1;
if ( dfs ( v , dep + 1 ) ){
path[dep] = i;
return 1;
}
vis[j] = 0;
}
}
return 0;
}

void recover (){
memcpy ( map , copy , sizeof ( copy ) );
memset ( vis , 0 , sizeof ( vis ) );
}

void deal (){
int i , j;
for ( i = 0 ; i <= 6 ; i++ ){
recover ();
if ( dfs ( i , 0 ) ) break;
}
if ( i <= 6 ){
for ( i = 0 ; i < m ; i++ ){
j = path[i];
printf ( "%d %cn" , e[j].id , e[j].state ? '-' : '+' );
}
}
else puts ( "No solution" );
}

int main (void){
//freopen ( "1001.in" , "r" , stdin );
//freopen ( "1001.out" , "w" , stdout );
while ( ~scanf ( "%d" , &m ) ){
input ();
deal ();
}
return 0;
}