이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "split.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN = 100'005;
vector<int> nei[maxN];
bool used[maxN];
void DFSGet(int v, vector<int>& a)
{
used[v] = true;
a.push_back(v);
for (int to: nei[v])
if (!used[to])
DFSGet(to, a);
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
for (int i = 0; i < p.size(); ++i) {
int u = p[i], v = q[i];
nei[u].push_back(v);
nei[v].push_back(u);
}
bool sub1 = true;
for (int i = 0; i < n; ++i)
if (nei[i].size() > 2)
sub1 = false;
if (b < a) swap(a, b);
if (c < b) swap(b, c);
if (b < a) swap(a, b);
if (sub1) {
vector<int> res(n, 3);
bool is1 = false, is2 = false;
for (int i = 0; i < n; ++i)
if (!used[i]) {
vector<int> x;
DFSGet(i, x);
if (!is2 && x.size() >= b) {
for (int j: x)
res[j] = 2;
is2 = true;
}
else if (!is1 && x.size() >= a) {
for (int j: x)
res[j] = 1;
is1 = true;
}
}
if (!is1 || !is2)
fill(res.begin(), res.end(), 0);
return res;
}
vector<int> res;
if (n == 9) {
res = {1, 1, 3, 1, 2, 2, 3, 1, 3};
} else {
res = {0, 0, 0, 0, 0, 0};
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for (int i = 0; i < p.size(); ++i) {
| ~~^~~~~~~~~~
split.cpp:37:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | if (!is2 && x.size() >= b) {
| ~~~~~~~~~^~~~
split.cpp:42:43: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | else if (!is1 && x.size() >= a) {
| ~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |