이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "split.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 3e2;
vector<int> perm = {0, 1, 2};
void sort(int &a, int &b, int &c){
vector<int> v = {a, b, c};
do {
a = v[perm[0]], b = v[perm[1]], c = v[perm[2]];
if (a <= b && b <= c) break;
} while (next_permutation(perm.begin(), perm.end()));
}
vector<int> orig(vector<int> v){
vector<int> res = v;
for (int i = 0; i < v.size(); i++){
res[i] = perm[v[i] - 1] + 1;
}
return res;
}
vector<int> g[MAXN];
bool used[MAXN];
vector<int> ord;
void dfs(int v){
used[v] = true;
ord.push_back(v);
for (int u : g[v]){
if (!used[u]) dfs(u);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int> res(n, 0);
sort(a, b, c);
int m = p.size();
for (int i = 0; i < m; i++){
g[p[i]].push_back(q[i]);
g[q[i]].push_back(p[i]);
}
int ind = 0;
for (int i = 0; i < n; i++){
if (g[i].size() < g[ind].size()) ind = i;
}
dfs(ind);
for (int i = 0; i < n; i++){
if (i < a) res[ord[i]] = 1; else
if (i < a + b) res[ord[i]] = 2; else
res[ord[i]] = 3;
}
return orig(res);
}
/*
7 6
1 2 4
0 1
1 2
2 3
3 4
4 5
5 6
*/
컴파일 시 표준 에러 (stderr) 메시지
split.cpp: In function 'std::vector<int> orig(std::vector<int>)':
split.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for (int i = 0; i < v.size(); i++){
| ~~^~~~~~~~~~
# | 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... |