Submission #9379

# Submission time Handle Problem Language Result Execution time Memory
9379 2014-09-28T06:01:32 Z dolpang2 Your life (kriii2_Y) C++14
Compilation error
0 ms 0 KB
#include <cstdio>
#include <vector>

std::vector<bool> visited;
std::vector< std::vector<int> > graph;

void DFS(int u, int V, int count) {
  visited[u] = true;
  for (int i = u + 1; i <= V; i++)
    if (graph[u][i] && !visited[i]) {
      int c = count + 1;
      if (i == V) {
        printf("%d\n", c - 1);
        exit(0);
      }
      DFS(i, V, c);
    }
}

int main() {
  int N = 0;
  int M = 0;

  scanf("%d%d", &N, &M);
  std::vector<int> row;
  for (int i = 0; i < N + 1; ++i) {
    row.push_back(0);
    visited.push_back(false);
  }
  for (int i = 0; i < N + 1; ++i) {
    graph.push_back(row);
  }

  for (int i = 0; i < M; ++i) {
    int x;
    int y;

    scanf("%d%d", &x, &y);
    graph[x][y] = 1;
  }
  DFS(1, N, 0);

}

Compilation message

Y.cpp: In function 'void DFS(int, int, int)':
Y.cpp:14:15: error: 'exit' was not declared in this scope
Y.cpp: In function 'int main()':
Y.cpp:24:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
Y.cpp:38:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]