-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathc.cc
37 lines (34 loc) · 729 Bytes
/
c.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// https://codeforces.com/contest/1068/problem/C
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main() {
int n, m;
cin >> n >> m;
vvi g(n);
vvi h(n);
for (int i = 0; i < m; i++) {
int u,v;
cin >> u >> v;
u--;v--;
if (v<u) swap(u,v);
g[u].push_back(v);
}
int x = 0;
for (int i = 0; i < n; i++) {
sort(g[i].begin(), g[i].end());
h[i].push_back(x++);
for (auto u:g[i]) {
h[i].push_back(x);
h[u].push_back(x);
x++;
}
}
for (int i = 0; i < n; i++) {
cout << h[i].size() << endl;
for (int j = 0; j < h[i].size(); j++) cout << h[i][j]+1 << " " << i+1 << endl;
}
}