Practice for Microsoft 2015 Online Test register

Ended

Participants:1406

Verdict:Runtime Error
Score:0 / 100
Submitted:2014-10-18 14:27:31

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <vector>
using namespace std;
vector<vector<int> > M;
int P[150][150];
bool visited[150];
vector<int> path;
bool dfs(int curx, int target){
    if(curx==target){
        if(path.size()==0) return true;
        bool flag=true;
        path.push_back(curx);
        for(int i=1;i<path.size();++i) 
        {
            if(P[path[i-1]][path[i]]){
                flag=false;
                break;
            }
            else P[path[i-1]][path[i]]=1;
        }
        path.pop_back();
        return flag;
    }
    else{
        path.push_back(curx);
        visited[curx]=true;
        bool flag=false;
        for(int i=0;i<M[curx].size();++i){
            int t=M[curx][i];
            if(!visited[t]) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX