Submission #667617

# Submission time Handle Problem Language Result Execution time Memory
667617 2022-12-01T19:51:26 Z berr Star Trek (CEOI20_startrek) C++17
8 / 100
1000 ms 5156 KB
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+37;
vector<int> adj[N], adj2[N];
int huh, huuh;

int dfs2(int v, int p, int d)
{
    int f=1;

    if(d%2==0) f=0;

    int count=0, val=0;

    for(auto i: adj2[v])
    {
        if(i==p) continue;

        if(dfs2(i, v, d+1))
        {
         
            if(d%2==0){
                f=1;
            }
        }
        else
        {
            if(d%2) f=0;
        }
    }




    return f;
}


int dfs(int v, int p, int d)
{
    int f=1;

    if(d%2==0) f=0;

    int count=0, val=0;

    for(auto i: adj[v])
    {
        if(i==p) continue;

        if(dfs(i, v, d+1))
        {
         
            if(d%2==0){
                f=1;
            }
        }
        else
        {
            if(d%2) f=0;
        }
    }

    if(huh==v)
    {   
        if(dfs2(huuh, 0, d+1)) 
        {
            if(d%2==0) f=1;
        }
        else
        {
            if(d%2) f=0;
        }
    }

    return f;
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, d; cin>>n>>d;


    for(int i=0; i<n-1; i++){
        int x, y; cin>>x>>y;

        adj[x].push_back(y);
        adj[y].push_back(x);

        adj2[x].push_back(y);
        adj2[y].push_back(x);
    }

    int ans=0;

    if(n<=1e4)
    {
        for(int i=1; i<=n; i++)
        {
            for(int l=1; l<=n; l++)
            {
                huh=i;
                huuh=l;
                if(dfs(1, 0, 0)) ans++;
            }
        }
    }

    cout<<ans;
}

Compilation message

startrek.cpp: In function 'int dfs2(int, int, int)':
startrek.cpp:13:9: warning: unused variable 'count' [-Wunused-variable]
   13 |     int count=0, val=0;
      |         ^~~~~
startrek.cpp:13:18: warning: unused variable 'val' [-Wunused-variable]
   13 |     int count=0, val=0;
      |                  ^~~
startrek.cpp: In function 'int dfs(int, int, int)':
startrek.cpp:45:9: warning: unused variable 'count' [-Wunused-variable]
   45 |     int count=0, val=0;
      |         ^~~~~
startrek.cpp:45:18: warning: unused variable 'val' [-Wunused-variable]
   45 |     int count=0, val=0;
      |                  ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Execution timed out 1096 ms 5076 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4948 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 18 ms 5012 KB Output is correct
3 Correct 22 ms 5040 KB Output is correct
4 Correct 15 ms 5032 KB Output is correct
5 Correct 16 ms 5028 KB Output is correct
6 Correct 17 ms 5028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 18 ms 5012 KB Output is correct
3 Correct 22 ms 5040 KB Output is correct
4 Correct 15 ms 5032 KB Output is correct
5 Correct 16 ms 5028 KB Output is correct
6 Correct 17 ms 5028 KB Output is correct
7 Execution timed out 1086 ms 5156 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 18 ms 5012 KB Output is correct
3 Correct 22 ms 5040 KB Output is correct
4 Correct 15 ms 5032 KB Output is correct
5 Correct 16 ms 5028 KB Output is correct
6 Correct 17 ms 5028 KB Output is correct
7 Execution timed out 1086 ms 5156 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 18 ms 5012 KB Output is correct
3 Correct 22 ms 5040 KB Output is correct
4 Correct 15 ms 5032 KB Output is correct
5 Correct 16 ms 5028 KB Output is correct
6 Correct 17 ms 5028 KB Output is correct
7 Execution timed out 1086 ms 5156 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 18 ms 5012 KB Output is correct
3 Correct 22 ms 5040 KB Output is correct
4 Correct 15 ms 5032 KB Output is correct
5 Correct 16 ms 5028 KB Output is correct
6 Correct 17 ms 5028 KB Output is correct
7 Execution timed out 1086 ms 5156 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Execution timed out 1096 ms 5076 KB Time limit exceeded
3 Halted 0 ms 0 KB -