이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);
int n, m, a, b;
vector<int> s[500005];
map<int, int> mp[500005];
vector<int> v;
vector<int> ost;
int bio[500005];
vector<int> rj[500005];
int sol = 0;
void dfs(int x) {
while (s[x].size() > 0) {
while (s[x].size() > 0 && mp[min(x, s[x].back())][max(x, s[x].back())] == 1) s[x].pop_back();
if (s[x].size() == 0) break;
int sus = s[x].back();
s[x].pop_back();
mp[min(x, sus)][max(x, sus)] = 1;
dfs(sus);
}
v.push_back(x);
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> a >> b;
s[a].push_back(b);
s[b].push_back(a);
}
dfs(1);
reverse(v.begin(), v.end());
int kol = 0;
for (int i = 0; i < v.size(); i++) {
if (bio[v[i]]) {
rj[sol].push_back(v[i]);
while (ost.back() != v[i]) {
rj[sol].push_back(ost.back());
bio[ost.back()]--;
ost.pop_back();
}
kol += rj[sol].size();
sol++;
}
else {
bio[v[i]] = 1;
ost.push_back(v[i]);
}
}
if (kol != m) assert(0);
for (int i = 0; i < sol; i++) {
for (int j = 0; j < rj[i].size(); j++) cout << rj[i][j] << " ";
cout << "\n";
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
postmen.cpp: In function 'int main()':
postmen.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for (int i = 0; i < v.size(); i++) {
| ~~^~~~~~~~~~
postmen.cpp:68:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for (int j = 0; j < rj[i].size(); j++) cout << rj[i][j] << " ";
| ~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |