(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #1119377

#제출 시각아이디문제언어결과실행 시간메모리
1119377kiethm07Cats or Dogs (JOI18_catdog)C++11
38 / 100
3067 ms7376 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define iii pair<int,pii> #define fi first #define se second #define vi vector<int> #define all(x) x.begin(),x.end() #define TEXT "a" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int inf = 1e9 + 7; const ld eps = 1e-8; const double pi = acos(-1); const int N = 1e5 + 5; int n; vector<int> a[N]; int f[N], g[N]; int type[N]; int pa[N]; void dfs(int u,int p){ for (int i = 0; i < a[u].size(); i++){ int v = a[u][i]; if (v == p) continue; pa[v] = u; dfs(v,u); } } void brute(int u,int p){ if (type[u] == 0) f[u] = g[u] = 0; if (type[u] == 1) f[u] = 0, g[u] = inf; if (type[u] == 2) f[u] = inf, g[u] = 0; for(int v : a[u]){ if (v == p) continue; brute(v,u); if (f[u] != inf) f[u] += min(f[v], g[v] + 1); if (g[u] != inf) g[u] += min(f[v] + 1, g[v]); } } void initialize(int N,vector<int> u, vector<int> v){ n = N; for (int i = 0; i < n - 1; i++){ a[u[i]].push_back(v[i]); a[v[i]].push_back(u[i]); } dfs(1,-1); } int cat(int u){ type[u] = 1; brute(1,-1); return min(f[1], g[1]); } int dog(int u){ type[u] = 2; brute(1,-1); return min(f[1], g[1]); } int neighbor(int u){ type[u] = 0; brute(1,-1); return min(f[1], g[1]); }

컴파일 시 표준 에러 (stderr) 메시지

catdog.cpp: In function 'void dfs(int, int)':
catdog.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for (int i = 0; i < a[u].size(); i++){
      |                     ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...