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
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include <bits/stdc++.h>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
#pragma GCC target("sse,sse2,sse3,mmx,abm,tune=native") // for szkopul and sio only
typedef long long lld;
typedef double lf;
typedef long double llf;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define For(i,s,a) for(lld i = (lld)s; i < (lld)a; ++i)
#define rpt(s, it) for(auto it = s.begin(); it != s.end(); ++it)
#define brpt(s, it) for(auto it = s.rend(); it != s.rbegin(); --it)
#define pb push_back
#define eb emplace_back
#define ff first
#define dd second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).erase( unique(all(x)), (x).end())
#define popcnt(x) __builtin_popcount(x)
#define sz size()
#define time_since duration_cast< milliseconds >(system_clock::now().time_since_epoch())
 
template<typename Ta, typename Tb>
ostream & operator <<(ostream & os, pair<Ta, Tb> x){
	return os << x.ff << " " << x.dd;
}

const int N = 1e5 + 1;
int ans[N];
vector<pii>c;

struct flow
{
	int n, zr, uj;
	vector<vector<pair<int,pair<lld*,lld*>>>> graf;
	vector<vector<pair<int,pair<lld*,lld*>>>> dgraf;
	vector<vector<lld>> ori;//do odzyskiwania flowu
	vector<int> odl;
	flow(){}
	flow(int vertex_limit) { //n jest jest inicjalizowane! porównuj graf.sz
		graf.resize(vertex_limit + 1);
		dgraf.resize(vertex_limit + 1);
		odl.resize(vertex_limit + 1, 0);
		ori.resize(vertex_limit + 1);//do odzyskiwania flowu
	}
	bool iszero(lld v) {
		return (!v);//zmienic dla dabli
	}
	void add_edge(int v, int u, lld lim, bool bi_dir=false) {
	//	cout << v << " adding " << u << endl;
		lld *a=new lld(lim);
		lld *b=new lld(lim*bi_dir);
		graf[v].push_back({u,{a, b}});
		graf[u].push_back({v,{b, a}});
		ori[v].push_back(lim);//do odzyskiwania flowu
		ori[u].push_back(lim*bi_dir);//do odzyskiwania flowu
	}
	void bfs() {
		for (int i=1; i<=n; i++) {
			odl[i]=0;
			dgraf[i].clear();
		}
		queue <int> kol;
		kol.push(zr);
		odl[zr]=1;
		while(!kol.empty()) {
			int v=kol.front();
			kol.pop();
			for (auto i : graf[v]) {
				if (!odl[i.first] && !iszero(*i.second.first)) {
					odl[i.first]=odl[v]+1;
					kol.push(i.first);
				}
				if (odl[i.first]==odl[v]+1 && !iszero(*i.second.first)) {
					dgraf[v].push_back(i);
//					cout << v << " x D " << i.first << endl;
				}
			}
		}
	}
	lld dfs(int v, lld lim) {
		if (v==uj)
			return lim;
		lld ret=0;
		for (int i=0; i<(int)dgraf[v].size() && !iszero(lim); i++) {
			auto &j=dgraf[v][i];
			lld wez=0;
			if (!iszero(*j.second.first))
				wez=dfs(j.first, min(*j.second.first, lim));
			if (iszero(wez)) {
				swap(dgraf[v][i], dgraf[v].back());
				dgraf[v].pop_back();
				i--;
				continue;
			}
			ret+=wez;
			(*j.second.first)-=wez;
			(*j.second.second)+=wez;
			lim-=wez;
		}
		return ret;
	}
	lld dinic(int nn, int zrzr, int ujuj) {
		n=nn;
		zr=zrzr;
		uj=ujuj;
		lld ret=0;
		while(1) {
			bfs();
			lld sta=ret;
			if (iszero(sta-(ret+=dfs(zr, 1e18))))//cos wiekszego niz maxflow, uwaga na overflow
				break;
		}
		return ret;
	}
	//ponizszych nie trzeba przepisywac
	void clear_memory() {
		for (int i=1; i<=n; i++)
			for (auto j : graf[i])
				delete(j.second.first);
	}
	//do ponizszych najpierw uzyc dinic()
	vector <int> cut() {
		vector <int> ret;
		bfs();
		for (int i=1; i<=n; i++)
			if (odl[i])
				ret.push_back(i);
		return ret;
	}
	map<pair<int,int>,lld> get_flowing() {//tam gdzie plynie 0 moze nie byc zainicjowane
		map<pair<int,int>,lld> ret;
		for (int i=1; i<=n; i++)
			for (int j=0; j<(int)graf[i].size(); j++)
				if ((*graf[i][j].second.first)<ori[i][j])
					ret[{i,graf[i][j].first}]+=ori[i][j]-(*graf[i][j].second.first);
		for (auto i : ret) {
			lld x=min(i.second, ret[{i.first.second,i.first.first}]);
			ret[i.first]-=x;
			ret[{i.first.second,i.first.first}]-=x;
		}
		return ret;
	}
};

void solve(void) {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	For(i, 0, m) {
		int g, h;
		scanf("%d%d", &g, &h);
		if(g <= k && h <= k)
			continue;
		c.pb(mp(g, h));
	}
	sort(all(c));
	make_unique(c);
	For(i, k + 1, n + 1)
	For(j, i, n + 1) {
		flow dccfuj(n * 2 + 69);
		for(auto s : c)
			dccfuj.add_edge(s.ff << 1 | 1, s.dd << 1, 1);
		For(l, 0, k)
			dccfuj.add_edge(0, (l + 1) << 1, 1);
		For(l, i, j + 1)
			dccfuj.add_edge(l << 1 | 1, n * 2 + 42, 1);
		For(l, 1, n + 1)
			dccfuj.add_edge(l << 1, l << 1 | 1, 1);
		int res = dccfuj.dinic(n * 2 + 42, 0, n * 2 + 42);
		ans[res]++;
		//cout << i << " " << j << " " << res << endl;
	}
	For(i, 0, k + 1)
		printf("%d ", ans[i]);
	
}

int32_t main(void){
	int t = 1;
	//scanf("%d", &t);
	while(t--)
		solve();
}