Submission #54369

# Submission time Handle Problem Language Result Execution time Memory
54369 2018-07-03T09:13:56 Z Costin Andrei Oncescu(#1303) Pipes (CEOI15_pipes) C++11
0 / 100
1683 ms 6692 KB
#include<bits/stdc++.h>

using namespace std;

int N, M, lev[100009], up[100009];
vector < int > v[100009];

int t[2][100009];
int tata (int lin, int i)
{
    if (t[lin][i] == i) return i;
    return t[lin][i] = tata (lin, t[lin][i]);
}

void dfs (int nod, int tata)
{
    up[nod] = lev[nod];
    for (auto it : v[nod])
        if (lev[it] == 0)
        {
            lev[it] = lev[nod] + 1;
            dfs (it, nod);
            if (up[it] > lev[nod])
                printf ("%d %d\n", it, nod);
        }
    bool firstException = 1;
    for (auto it : v[nod])
        if (it == tata && firstException == 1) firstException = 0;
        else
        if (up[it] < up[nod]) up[nod] = up[it];
}

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

scanf ("%d %d", &N, &M);
for (int i=1; i<=N; i++)
    t[0][i] = t[1][i] = i;
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    if (tata (0, x) != tata (0, y))
        t[0][tata (0, x)] = tata (0, y),
        v[x].push_back (y),
        v[y].push_back (x);
    else
    if (tata (1, x) != tata (1, y))
        t[1][tata (1, x)] = tata (1, y);
}
return 0;
for (int i=1; i<=N; i++)
    if (tata (1, i) != i)
        v[tata (1, i)].push_back (i),
        v[i].push_back (tata (1, i));
for (int i=1; i<=N; i++)
    if (lev[i] == 0)
        lev[i] = 1, dfs (i, -1);
return 0;
}

Compilation message

pipes.cpp: In function 'int main()':
pipes.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d %d", &N, &M);
 ~~~~~~^~~~~~~~~~~~~~~~~
pipes.cpp:44:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &x, &y);
     ~~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2660 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 2816 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 118 ms 2816 KB Output is correct
2 Incorrect 114 ms 2816 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 200 ms 3044 KB Output is correct
2 Incorrect 234 ms 3084 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 330 ms 3576 KB Output is correct
2 Incorrect 285 ms 3944 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 456 ms 5424 KB Output is correct
2 Incorrect 401 ms 5436 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 718 ms 5852 KB Output is correct
2 Incorrect 692 ms 5788 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 949 ms 6692 KB Output is correct
2 Incorrect 920 ms 6648 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 1204 ms 6548 KB Output is correct
2 Incorrect 1211 ms 6520 KB Wrong number of edges
# Verdict Execution time Memory Grader output
1 Correct 1683 ms 6520 KB Output is correct
2 Incorrect 1379 ms 6684 KB Wrong number of edges