#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
map<ll,ll> sus;
map<ll,ll> sus2;
map<ll,ll> cnts;
set<vector<ll>> stuff[100005];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,s,t;
cin >> n >> s >> t;
vector<vector<ll>> cores;
vector<vector<ll>> orient(n);
FOR(i,0,n){
ll a,b;
cin >> a >> b;
cores.push_back({a,b});
stuff[a].insert({b,i});
stuff[b].insert({a,i});
cnts[a]++;
cnts[b]++;
}
ll cnt = 1;
vector<ll> urg;
FOR(i,1,n+1) if (stuff[i].size()==1) urg.push_back(i);
while (cnt < n){
if (stuff[cnt].size()==0) cnt++;
ll cur = cnt;
while (urg.size() && stuff[urg[urg.size()-1]].size() != 1) urg.pop_back();
if (urg.size()){
cur = urg[urg.size()-1];
urg.pop_back();
}
ll pos = 0;
if (sus[cur] == (cnts[cur]+1)/2){
pos = 1;
}
while (1){
if (stuff[cur].size()==0) break;
vector<ll> node = (*stuff[cur].begin());
if (pos==0){
orient[node[1]] = {cur, node[0]};
sus[cur]++;
sus2[node[0]]++;
}else{
orient[node[1]] = {node[0], cur};
sus[node[0]]++;
sus2[cur]++;
}
stuff[cur].erase(node);
stuff[node[0]].erase({cur, node[1]});
if (stuff[cur].size() == 1) urg.push_back(cur);
if (stuff[node[0]].size() == 1) urg.push_back(node[0]);
cur = node[0];
if (cur == cnt) break;
}
}
for (auto&i : orient){
cout << i[0] << " " << i[1] << "\n";
}
// cout << endl;
// FOR(i,1,t+1){
// cout << sus[i] << " " << sus2[i] << endl;
// }
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
5208 KB |
Correct |
2 |
Incorrect |
2 ms |
4952 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Correct |
2 |
Correct |
2 ms |
4956 KB |
Correct |
3 |
Correct |
2 ms |
4956 KB |
Correct |
4 |
Correct |
2 ms |
4956 KB |
Correct |
5 |
Correct |
2 ms |
4956 KB |
Correct |
6 |
Correct |
2 ms |
4952 KB |
Correct |
7 |
Correct |
2 ms |
4956 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
312 ms |
38680 KB |
Correct |
2 |
Correct |
231 ms |
37940 KB |
Correct |
3 |
Correct |
231 ms |
32252 KB |
Correct |
4 |
Correct |
151 ms |
31820 KB |
Correct |
5 |
Correct |
232 ms |
36560 KB |
Correct |
6 |
Correct |
313 ms |
40444 KB |
Correct |
7 |
Correct |
319 ms |
40176 KB |
Correct |
8 |
Correct |
311 ms |
41984 KB |
Correct |
9 |
Correct |
342 ms |
41900 KB |
Correct |
10 |
Correct |
137 ms |
42144 KB |
Correct |
11 |
Correct |
132 ms |
41984 KB |
Correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
312 ms |
38680 KB |
Correct |
2 |
Correct |
231 ms |
37940 KB |
Correct |
3 |
Correct |
231 ms |
32252 KB |
Correct |
4 |
Correct |
151 ms |
31820 KB |
Correct |
5 |
Correct |
232 ms |
36560 KB |
Correct |
6 |
Correct |
313 ms |
40444 KB |
Correct |
7 |
Correct |
319 ms |
40176 KB |
Correct |
8 |
Correct |
311 ms |
41984 KB |
Correct |
9 |
Correct |
342 ms |
41900 KB |
Correct |
10 |
Correct |
137 ms |
42144 KB |
Correct |
11 |
Correct |
132 ms |
41984 KB |
Correct |
12 |
Correct |
379 ms |
38868 KB |
Correct |
13 |
Correct |
320 ms |
37860 KB |
Correct |
14 |
Correct |
259 ms |
32252 KB |
Correct |
15 |
Correct |
182 ms |
32000 KB |
Correct |
16 |
Correct |
237 ms |
36352 KB |
Correct |
17 |
Correct |
291 ms |
40296 KB |
Correct |
18 |
Correct |
280 ms |
39936 KB |
Correct |
19 |
Correct |
257 ms |
41964 KB |
Correct |
20 |
Correct |
282 ms |
41980 KB |
Correct |
21 |
Correct |
130 ms |
41964 KB |
Correct |
22 |
Correct |
126 ms |
41880 KB |
Correct |
23 |
Incorrect |
300 ms |
40256 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4956 KB |
Correct |
2 |
Correct |
2 ms |
4956 KB |
Correct |
3 |
Correct |
2 ms |
4956 KB |
Correct |
4 |
Correct |
2 ms |
4956 KB |
Correct |
5 |
Correct |
2 ms |
4956 KB |
Correct |
6 |
Correct |
2 ms |
4952 KB |
Correct |
7 |
Correct |
2 ms |
4956 KB |
Correct |
8 |
Correct |
312 ms |
38680 KB |
Correct |
9 |
Correct |
231 ms |
37940 KB |
Correct |
10 |
Correct |
231 ms |
32252 KB |
Correct |
11 |
Correct |
151 ms |
31820 KB |
Correct |
12 |
Correct |
232 ms |
36560 KB |
Correct |
13 |
Correct |
313 ms |
40444 KB |
Correct |
14 |
Correct |
319 ms |
40176 KB |
Correct |
15 |
Correct |
311 ms |
41984 KB |
Correct |
16 |
Correct |
342 ms |
41900 KB |
Correct |
17 |
Correct |
137 ms |
42144 KB |
Correct |
18 |
Correct |
132 ms |
41984 KB |
Correct |
19 |
Correct |
379 ms |
38868 KB |
Correct |
20 |
Correct |
320 ms |
37860 KB |
Correct |
21 |
Correct |
259 ms |
32252 KB |
Correct |
22 |
Correct |
182 ms |
32000 KB |
Correct |
23 |
Correct |
237 ms |
36352 KB |
Correct |
24 |
Correct |
291 ms |
40296 KB |
Correct |
25 |
Correct |
280 ms |
39936 KB |
Correct |
26 |
Correct |
257 ms |
41964 KB |
Correct |
27 |
Correct |
282 ms |
41980 KB |
Correct |
28 |
Correct |
130 ms |
41964 KB |
Correct |
29 |
Correct |
126 ms |
41880 KB |
Correct |
30 |
Incorrect |
300 ms |
40256 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
31 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4956 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4956 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4956 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
312 ms |
38680 KB |
Correct |
2 |
Correct |
231 ms |
37940 KB |
Correct |
3 |
Correct |
231 ms |
32252 KB |
Correct |
4 |
Correct |
151 ms |
31820 KB |
Correct |
5 |
Correct |
232 ms |
36560 KB |
Correct |
6 |
Correct |
313 ms |
40444 KB |
Correct |
7 |
Correct |
319 ms |
40176 KB |
Correct |
8 |
Correct |
311 ms |
41984 KB |
Correct |
9 |
Correct |
342 ms |
41900 KB |
Correct |
10 |
Correct |
137 ms |
42144 KB |
Correct |
11 |
Correct |
132 ms |
41984 KB |
Correct |
12 |
Incorrect |
2 ms |
4956 KB |
Unexpected end of file - int32 expected |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
312 ms |
38680 KB |
Correct |
2 |
Correct |
231 ms |
37940 KB |
Correct |
3 |
Correct |
231 ms |
32252 KB |
Correct |
4 |
Correct |
151 ms |
31820 KB |
Correct |
5 |
Correct |
232 ms |
36560 KB |
Correct |
6 |
Correct |
313 ms |
40444 KB |
Correct |
7 |
Correct |
319 ms |
40176 KB |
Correct |
8 |
Correct |
311 ms |
41984 KB |
Correct |
9 |
Correct |
342 ms |
41900 KB |
Correct |
10 |
Correct |
137 ms |
42144 KB |
Correct |
11 |
Correct |
132 ms |
41984 KB |
Correct |
12 |
Correct |
379 ms |
38868 KB |
Correct |
13 |
Correct |
320 ms |
37860 KB |
Correct |
14 |
Correct |
259 ms |
32252 KB |
Correct |
15 |
Correct |
182 ms |
32000 KB |
Correct |
16 |
Correct |
237 ms |
36352 KB |
Correct |
17 |
Correct |
291 ms |
40296 KB |
Correct |
18 |
Correct |
280 ms |
39936 KB |
Correct |
19 |
Correct |
257 ms |
41964 KB |
Correct |
20 |
Correct |
282 ms |
41980 KB |
Correct |
21 |
Correct |
130 ms |
41964 KB |
Correct |
22 |
Correct |
126 ms |
41880 KB |
Correct |
23 |
Incorrect |
300 ms |
40256 KB |
maximum and minimum number of simultaneously evaluated submissions for any single task differ more than one |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
5208 KB |
Correct |
2 |
Incorrect |
2 ms |
4952 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |