#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[100000];
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;
if (a==b){
orient[i] = {a,b};
continue;
}
cores.push_back({a,b});
stuff[a].insert({b,i});
stuff[b].insert({a,i});
}
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();
}
while (1){
if (stuff[cur].size()==0) break;
vector<ll> node = (*stuff[cur].begin());
orient[node[1]] = {cur, node[0]};
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){
sus[i[0]]++;
sus2[i[1]]++;
cout << i[0] << " " << i[1] << endl;
}
cout << endl;
FOR(i,1,t+1){
cout << sus[i] << " " << sus2[i] << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4956 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4952 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
448 ms |
35332 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
448 ms |
35332 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4952 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4952 KB |
Integer 0 violates the range [1, 3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4952 KB |
Integer 0 violates the range [1, 3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4952 KB |
Integer 0 violates the range [1, 3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
448 ms |
35332 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
448 ms |
35332 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4956 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |