이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "split.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int>adj[n];
const int m = (int)p.size();
for(int i = 0 ; i < m ; i++) {
adj[p[i]].push_back(q[i]);
adj[q[i]].push_back(p[i]);
}
vector<int>col(n,0);
int start = 0;
for(int i = 0 ; i < n ; i++)
if((int)adj[i].size() == 1)
start = i;
stack<int>s;
s.push(start);
int sz = 0;
col[start] = 2;
vector<bool>vis(n,0);
vis[start] = 1;
vector<bool>real(n,0);
real[start] = 1;
while(sz < b) {
int node = s.top();
s.pop();
real[node] = 1;
col[node] = 2;
sz++;
for(auto z : adj[node]) if(!vis[z]) {
s.push(z);
vis[z] = 1;
}
}
vis.clear();
vis.resize(n,0);
for(int i = 0 ; i < n ; i++) {
if(!real[i]) {
while(!s.empty())
s.pop();
s.push(i);
sz = 0;
vis[i] = 1;
col[i] = 1;
while(sz < a) {
int node = s.top();
s.pop();
sz++;
col[node] = 1;
for(auto z : adj[node]) if(!vis[z] && !real[z]) {
s.push(z);
vis[z] = 1;
}
}
break;
}
}
for(int i = 0 ; i < n ; i++)
if(!col[i])
col[i] = 3;
return col;
}
/*
//#include "split.h"
#include <cstdio>
#include <cassert>
using namespace std;
int main() {
int n, m, a, b, c;
assert(5 == scanf("%d%d%d%d%d", &n, &m, &a, &b, &c));
vector<int> p(m), q(m);
for (int i=0; i<m; i++)
assert(2 == scanf("%d%d", &p[i], &q[i]));
fclose(stdin);
vector<int> result = find_split(n, a, b, c, p, q);
for (int i=0; i<(int)result.size(); i++)
printf("%s%d", ((i>0)?" ":""), result[i]);
printf("\n");
fclose(stdout);
return 0;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:63:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
63 | for(int i = 0 ; i < n ; i++)
| ^~~
split.cpp:66:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
66 | return col;
| ^~~~~~
# | 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... |