Language: C++

#include "bits/stdc++.h"
using namespace std;

typedef vector<short> Weight;
struct Edge {
	int src, dest;
	int cap, rev;
	Weight weight;
	bool operator < (const Edge &rhs) const {
		for (int i = 0; i < weight.size(); ++i) {
			if (weight[i] > rhs.weight[i])return true;
			else if (weight[i] < rhs.weight[i])return false;
		}
		return false;
	}
};
Weight operator+(const Weight&l, const Weight&r) {
	Weight t(l);
	for (int i = 0; i < l.size(); ++i) {
		t[i] += r[i];
	}
	return t;
}
Weight operator-(const Weight&l, const Weight&r) {
	Weight t(l);
	for (int i = 0; i < l.size(); ++i) {
		t[i] -= r[i];
	}
	return t;
}
Weight operator*(const int&l, const Weight&r) {
	Weight t(r);
	for (int i = 0; i < r.size(); ++i) {
		t[i] *= l;
	}
	return t;
}
const int V =1100;
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
Weight h[V];                //??????????????£???
Weight dist[V];             //???????????¢
int prevv[V], preve[V];  //??´???????????¨??????

void add_edge(Graph &g, int src, int dest, int cap, Weight weight) {
	g[src].push_back(Edge{ src, dest, cap, (int)g[dest].size(), weight });
	Weight revweight(weight);
	{
		for (auto &e : revweight)e = -e;
	}
	g[dest].push_back(Edge{ dest, src, 0, (int)g[src].size() - 1, revweight });
}
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
Weight INF;
Weight ZERO;
//????????????double?????????eps?????????
Weight min_cost_flow(Graph &g, int s, int t, int f) {
	Weight res = ZERO;
	for (int i = 0; i < V; ++i)h[i] = ZERO;
	typedef pair<Weight, int> P;
	while (f > 0) {
		priority_queue<P, vector<P>, greater<P> > que;
		fill(dist, dist + V, INF);
		dist[s] = ZERO;
		que.push(make_pair( ZERO, s ));
		while (!que.empty()) {
			P p = que.top(); que.pop();
			const int v = p.second;
			if (dist[v] < p.first) continue;
			REP(i, g[v].size()) {
				Edge &e = g[v][i];
				auto nextw(dist[v] + e.weight + h[v] - h[e.dest]);
				if (e.cap > 0 && dist[e.dest] > nextw) {
					dist[e.dest] = move(nextw);
					prevv[e.dest] = v;
					preve[e.dest] = i;
					que.push(make_pair(dist[e.dest], e.dest ));
				}
			}
		}
		if (dist[t] == INF)return vector<int>(0, 0);
		REP(v, V) h[v] = h[v] + dist[v];

		int d = f;
		for (int v = t; v != s; v = prevv[v]) d = min(d, g[prevv[v]][preve[v]].cap);
		f -= d;
		res = res + d * h[t];
		for (int v = t; v != s; v = prevv[v]) {
			Edge &e = g[prevv[v]][preve[v]];
			e.cap -= d;
			g[v][e.rev].cap += d;
		}
	}
	return res;
}


int main() {
	int N; cin >> N;
	INF = vector<int>(N - 1,1000);
	ZERO = vector<int>(N - 1, 0);
	const int start = 0;
	const int in = start + 1;
	const int out = in + (N - 1);
	const int goal = out + (N - 1);
	Graph g(goal + 1);
	for (int i = 0; i < N - 1; ++i) {
		add_edge(g, start, in + i, 1, ZERO);
	}
	for (int i = 0; i < N - 1; ++i) {
		for (int j = 0; j < N - 1; ++j) {
			int a; cin >> a;
			if (a) {

				Weight cost(ZERO);
				cost[j] = i+1;
				add_edge(g, in + i, out + j, 1, cost);
			}
		}
	}
	for (int i = 0; i < N - 1; ++i) {
		add_edge(g, out + i,goal, 1, ZERO);
	}
	auto aa = min_cost_flow(g, start, goal, N - 1);
	if (aa.empty()) {
		cout << "no" << endl;
	}
	else {
		vector<int>ans(N - 1);
		for (int i = 0; i < N - 1; ++i) {
			ans[i] = aa[i];
		}
		cout << "yes" << endl;
		for (int i = 0; i < N - 1; ++i) {
			cout << ans[i] << endl;
		}
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'Weight min_cost_flow(Graph&, int, int, int)':
a.cc:85:43: error: could not convert 'std::vector<int>(0, 0, std::allocator<int>())' from 'vector<int>' to 'vector<short int>'
   85 |                 if (dist[t] == INF)return vector<int>(0, 0);
      |                                           ^~~~~~~~~~~~~~~~~
      |                                           |
      |                                           vector<int>
a.cc: In function 'int main()':
a.cc:104:37: error: no match for 'operator=' (operand types are 'Weight' {aka 'std::vector<short int>'} and 'std::vector<int>')
  104 |         INF = vector<int>(N - 1,1000);
      |                                     ^
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = short int; _Alloc = std::allocator<short int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<short int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = short int; _Alloc = std::allocator<short int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<short int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = short int; _Alloc = std::allocator<short int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<short int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:105:36: error: no match for 'operator=' (operand types are 'Weight' {aka 'std::vector<short int>'} and 'std::vector<int>')
  105 |         ZERO = vector<int>(N - 1, 0);
      |                                    ^
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = short int; _Alloc = std::allocator<short int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<short int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = short int; _Alloc = std::allocator<short int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<short int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = short int; _Alloc = std::allocator<short int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<short int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~