제출 #1040032

#제출 시각아이디문제언어결과실행 시간메모리
1040032LaMatematica14Split the Attractions (IOI19_split)C++17
22 / 100
485 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; vector<int> sz, pr; vector<vector<int>> adj; void dfs(int a, int p) { for (int x : adj[a]) { if (x == p) continue; dfs(x, a); pr[x] = a; sz[a] += sz[x]; } sz[a]++; } void dfs2(int a, int p, vector<int> &s, int col, int &q) { if (q == 0) return; s[a] = col; q--; for (int x : adj[a]) { if (q == 0) continue; if (x == p) continue; dfs2(x, a, s, col, q); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { array<pair<int, int>, 3> t; t[0] = {a, 1}; t[1] = {b, 2}; t[2] = {c, 3}; sort(t.begin(), t.end()); sz.resize(n); pr.resize(n); adj.resize(n); vector<int> g(n, 0); for (int i = 0; i < p.size(); i++) { adj[p[i]].push_back(q[i]); adj[q[i]].push_back(p[i]); } dfs(0, -1); for (int i = 1; i < n; i++) { if (sz[i] >= t[0].first && n-sz[i] >= t[1].first) { dfs2(i, pr[i], g, t[0].second, t[0].first); dfs2(pr[i], i, g, t[1].second, t[1].first); for (int i = 0; i < n; i++) { if (g[i] == 0) g[i] = t[2].second; } break; } else if (n-sz[i] >= t[0].first && sz[i] >= t[1].first) { dfs2(i, pr[i], g, t[1].second, t[1].first); dfs2(pr[i], i, g, t[0].second, t[0].first); for (int i = 0; i < n; i++) { if (g[i] == 0) g[i] = t[2].second; } break; } } return g; }

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

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i = 0; i < p.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...