답안 #41871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41871 2018-02-21T18:48:35 Z octopuses Pipes (CEOI15_pipes) C++14
0 / 100
2420 ms 3072 KB
//Giorgi Kldiashvili

#include <bits/stdc++.h>

#define ll long long
#define M 1000000007ll

using namespace std;
const int N = 100001;

int n, m, x, y, timer;

int p[N], P[N], c[N], d[N], in[N];
vector < int > G[N];
bool used[N];

int Parent(int x)
{
  if(P[x] == x)
    return x;
  return P[x] = Parent(P[x]);
}

void go(int v)
{
  c[v] = d[v] = in[v] = ++ timer;
  used[v] = true;
  for(int i = 0; i < G[v].size(); ++ i)
  {
    if(used[G[v][i]])
      continue;
    p[G[v][i]] = v;
    go(G[v][i]);
  }
}

void dfs(int v)
{
  used[v] = true;
  timer ++;
  for(int i = 0; i < G[v].size(); ++ i)
  {
    if(used[G[v][i]])
      continue;
    dfs(G[v][i]);
    c[v] = min(c[v], c[G[v][i]]);
    d[v] = max(d[v], d[G[v][i]]);
  }
  if(p[v] == 0)
    return;
  if(c[v] >= in[v] && d[v] <= timer)
    printf("%d %d\n", v, p[v]);
}

int main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  scanf("%d %d", &n, &m);

  for(int i = 1; i <= n; ++ i)
    P[i] = i;

  while(m --)
  {
    scanf("%d %d", &x, &y);
    continue;
    if(Parent(x) == Parent(y))
      continue;
    P[Parent(x)] = y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  rewind(stdin);
  timer = 0;
  scanf("%d %d", &n, &m);
  while(m --)
  {
    scanf("%d %d", &x, &y);
    continue;
    if(Parent(x) == Parent(y))
      continue;
    P[Parent(x)] = y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  return 0;


  scanf("%d %d", &n, &m);
  for(int i = 1; i <= n; ++ i)
    P[i] = i, used[i] = 0;
  while(m --)
  {
    scanf("%d %d", &x, &y);
    if(Parent(x) == Parent(y))
    {
      c[x] = min(c[x], in[y]);
      d[x] = max(d[x], in[y]);
      d[y] = max(d[y], in[x]);
      c[y] = min(c[y], in[x]);
      continue;
    }
    P[Parent(x)] = y;
  }
  for(int i = 1; i <= n; ++ i)
  {
    if(used[i]) continue;
    dfs(i);
  }
}

Compilation message

pipes.cpp: In function 'void go(int)':
pipes.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < G[v].size(); ++ i)
                  ~~^~~~~~~~~~~~~
pipes.cpp: In function 'void dfs(int)':
pipes.cpp:41:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < G[v].size(); ++ i)
                  ~~^~~~~~~~~~~~~
pipes.cpp: In function 'int main()':
pipes.cpp:60:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:67:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &x, &y);
     ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:77:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &x, &y);
     ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:91:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:96:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &x, &y);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2688 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2688 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 220 ms 2688 KB Output is correct
2 Incorrect 213 ms 2660 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 388 ms 2688 KB Output is correct
2 Incorrect 442 ms 2688 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 592 ms 2724 KB Output is correct
2 Incorrect 500 ms 2816 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 723 ms 2944 KB Output is correct
2 Incorrect 633 ms 2944 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 1167 ms 2972 KB Output is correct
2 Incorrect 1164 ms 2944 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 1541 ms 3072 KB Output is correct
2 Incorrect 1470 ms 3072 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 2093 ms 3072 KB Output is correct
2 Incorrect 1852 ms 3072 KB Wrong number of edges
# 결과 실행 시간 메모리 Grader output
1 Correct 2420 ms 3072 KB Output is correct
2 Incorrect 2379 ms 3072 KB Wrong number of edges