제출 #841670

#제출 시각아이디문제언어결과실행 시간메모리
841670Batrr참나무 (IOI23_beechtree)C++17
17 / 100
2054 ms63404 KiB
#include "beechtree.h" #include <bits/stdc++.h> #define f first #define s second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<long long, long long> pll; const int N = 300500, inf = 1e9, mod = 998244353; const ll INF = 1e18; vector<pii> g[N]; int n, m; int ans[N]; int P[N], C[N]; int tin[N], timer; vector<int> t[N]; int sz[N]; bool f(int v, int u) { for (int i = 0, j = 0; i < g[u].size(); i++) { while (j < g[v].size() && g[v][j].f != g[u][i].f) j++; if (j == g[v].size()) return false; if (!f(g[v][j].s, g[u][i].s)) return false; } return true; } void dfs(int v) { tin[v] = timer++; sz[v] = 1; ans[v] = 1; vector<int> a; for(int i = 0; i + 1 < g[v].size(); i++) ans[v] &= (g[v][i].f != g[v][i + 1].f); for (auto it: g[v]) { int to = it.s; a.pb(to); dfs(to); sz[v] += sz[to]; ans[v] &= ans[to]; ans[v] &= f(v, to); } sort(a.begin(), a.end(), [](int i, int j) { return sz[i] > sz[j]; }); for (int i = 0; i + 1 < a.size(); i++) ans[v] &= f(a[i], a[i + 1]); } vector<int> beechtree(int N, int M, vector<int> PP, vector<int> CC) { n = N; for (int i = 0; i < n; i++) { g[i].clear(); P[i] = PP[i]; C[i] = CC[i]; ans[i] = 0; } for (int i = 1; i < n; i++) g[P[i]].pb({C[i], i}); for (int i = 0; i < n; i++) sort(g[i].begin(), g[i].end()); dfs(0); return vector<int>(ans, ans + n); }

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

beechtree.cpp: In function 'bool first(int, int)':
beechtree.cpp:29:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0, j = 0; i < g[u].size(); i++) {
      |                            ~~^~~~~~~~~~~~~
beechtree.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         while (j < g[v].size() && g[v][j].f != g[u][i].f)
      |                ~~^~~~~~~~~~~~~
beechtree.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if (j == g[v].size())
      |             ~~^~~~~~~~~~~~~~
beechtree.cpp: In function 'void dfs(int)':
beechtree.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = 0; i + 1 < g[v].size(); i++)
      |                    ~~~~~~^~~~~~~~~~~~~
beechtree.cpp:58:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for (int i = 0; i + 1 < a.size(); i++)
      |                     ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...