Saratov State University :: Online Contester


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

::Poll
Are you registered on Codeforces?
Yes
No
What 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;
vector<PII> adj[200];

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;
FR(i,adj[v].size())
{
int u=adj[v][i].first, C=adj[v][i].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--;
adj[a].push_back(PII(b,c));
}

bfs();

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

return 0;
}


see sub-tree reply to that message


::Login
Forgot password?

::News
22.10.12 - The problems from the Southern Subregional Programming Contest 2012 added to the problemset archive (542 - 553).
22.10.12 - After the start of the contest the statements in PDF will be available by the link.
23.10.11 - The problems from the Southern Subregional Programming Contest 2011 added to the problemset archive (530 - 541).

::Counter

Server time: 2017-11-23 04:27:54Online Contester Team © 2002 - 2016. All rights reserved.