### 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

 Why WA on test10
Author: mohsen
ID: 053228
Problem: 226
Contest: 0
Date: 2012-07-06 16:25:30

Hi
This is my code, Can someone help me plz?

#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <sstream>
#include <stdio.h>

using namespace std;

#define MAX 10010
#define FR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define PII pair<int,int>

int dis[200],n,m;

void bfs()
{
queue<PII> q;
q.push(PII(0,4));
dis[0]=0;

int cnt=0;
while(!q.empty() && cnt++<88000)
{
PII cur=q.front(); q.pop();
int v=cur.first, c=cur.second;
{
if(C!=c)
{
dis[u]=dis[v]+1;
if(u==n-1) return;
q.push(PII(u,C));
}
}
}
}

int main()
{
//freopen("in.txt","r",stdin);

memset(dis,-1,sizeof dis);

cin>>n>>m;
FR(i,m)
{
int a,b,c; cin>>a>>b>>c;
a--; b--;
}

bfs();

cout<<dis[n-1]<<endl;

return 0;
}