Submission #864608

# Submission time Handle Problem Language Result Execution time Memory
864608 2023-10-23T10:25:34 Z vnm06 Duathlon (APIO18_duathlon) C++14
0 / 100
1000 ms 21500 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

long long n, m, en;
vector<int> gr[300005];

long long ans=0;
int post[3005];
int vzm[3005];

void dfs(int v)
{
    post[v]=1;
    int brs=gr[v].size();
    for(int i=0; i<brs; i++)
    {
        int nv=gr[v][i];
        if(post[nv]==1) continue;
        if(vzm[nv]==1) {vzm[v]=1; continue;}
        if(post[nv]) continue;
        dfs(nv);
    }
    post[v]=2;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int v, u;
        cin>>v>>u;
        gr[v].push_back(u);
        gr[u].push_back(v);
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            if(i==j) continue;
            en=j;
            post[en]=1;
            vzm[en]=1;
            dfs(i);
            for(int k=1; k<=n; k++)
            {
                if(k==i || k==j) continue;
                ans+=vzm[k];
                post[k]=vzm[k]=0;
            }
            cout<<ans<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}
/**
8 7
1 2
2 3
2 4
3 5
5 6
6 7
6 8


*/
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 7516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 7516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 246 ms 21076 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 8464 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 246 ms 21236 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 8848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 246 ms 21500 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 7516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 7516 KB Output isn't correct
2 Halted 0 ms 0 KB -