Submission #421514

# Submission time Handle Problem Language Result Execution time Memory
421514 2021-06-09T08:36:45 Z 장태환(#7576) Cats or Dogs (JOI18_catdog) C++17
0 / 100
2 ms 332 KB
#include "catdog.h"
#include <vector>
using namespace std;
int dp[1010][2];
vector<int>x[1010];
int sta[1010];
void initialize(int N, std::vector<int> A, std::vector<int> B)
{
    int i;
    for(i=0;i<N;i++)
    {
        x[A[i]].push_back(B[i]);
        x[B[i]].push_back(A[i]);
    }
}
int dfs(int n,int par)
{
    int i;
    for(i=0;i<x[n].size();i++)
    {
        if(x[n][i]!=par)
            dfs(x[n][i],n);
    }
    if(sta[n]!=1)
    {
        for(i=0;i<x[n].size();i++)
        {
            if(x[n][i]!=par)
                dp[i][0]+=max(dp[x[n][i]][0],dp[x[n][i]][1]+1);
        }
    }
    if(sta[n]!=2)
    {
        for(i=0;i<x[n].size();i++)
        {
            if(x[n][i]!=par)
                dp[i][1]+=max(dp[x[n][i]][1],dp[x[n][i]][0]+1);
        }
    }
}
int cat(int v)
{
    sta[v]=2;
    return dfs(1,0);
}

int dog(int v) {
    sta[v]=1;
    return dfs(1,0);
}

int neighbor(int v) {
  sta[v]=0;
  return dfs(1,0);
}

Compilation message

catdog.cpp: In function 'int dfs(int, int)':
catdog.cpp:19:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(i=0;i<x[n].size();i++)
      |             ~^~~~~~~~~~~~
catdog.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(i=0;i<x[n].size();i++)
      |                 ~^~~~~~~~~~~~
catdog.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(i=0;i<x[n].size();i++)
      |                 ~^~~~~~~~~~~~
catdog.cpp:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -