Language: C++

 
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

int32_t N;
int32_t M;
int32_t win[100000] = {};
int32_t undefined[100000];
int32_t win_max_index[100000];//??????
int32_t win_min_index[100000];//??????

int32_t indegrees[100000] = {};
std::vector<int32_t> graph[100000];
int32_t tp_sorted_index[100000] = {};

template<typename T>
void show_all(T b, T e) {
#ifdef _DEBUG
	out << "-------------------\n";
	while (b != e) {
		out << *(b++) << ' ';
	}
	out << "\n-------------------\n";
#endif
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N >> M;
	std::for_each(undefined, undefined + N, [](int32_t& i) {i = N - 1; });
	for (int32_t i = 0; i < M; ++i)
	{
		int32_t w, l;
		in >> w >> l; --w; --l;
		++win[w]; --undefined[w]; --undefined[l];
		graph[w].push_back(l); ++indegrees[l];
	}

#ifdef _DEBUG
	out << "-------------------\n";
	for (int32_t i = 0; i < N; ++i)
	{
		for (auto& e : graph[i]) {
			out << e<< ' ';
		}
		out << '(' << indegrees[i] << ')';
		out << win[i] << ' ' << undefined[i];
		out << endl;
	}
	out << "-------------------\n";
#endif
	show_all(indegrees, indegrees + N);
	
	//?????§/????°?????????°
	auto max_win_comp = [](int32_t i, int32_t j){return (win[i] + undefined[i]) > (win[j] + undefined[j]); };
	std::iota(win_max_index, win_max_index + N, 0i32);
	std::sort(win_max_index, win_max_index + N, max_win_comp);
	show_all(win_max_index, win_max_index + N);
	auto min_win_comp = [](int32_t i, int32_t j) {return win[i] > win[j]; };
	std::iota(win_min_index, win_min_index + N, 0i32);
	std::sort(win_min_index, win_min_index + N, min_win_comp);
	show_all(win_min_index, win_min_index + N);
	//?¢???????????????????????????£?????????
	for (auto iter = win_min_index, iter_ALL_end = win_min_index + N; iter != iter_ALL_end;)
	{
		auto iter_end = std::upper_bound(iter + 1, iter_ALL_end, *iter, min_win_comp);
		auto win_max_iter_b = std::upper_bound(win_max_index, win_max_index + N, *iter, 
			[](int32_t value, int32_t index) {return value > (win[index] + undefined[index]); });
		auto winmin_max = win[*win_max_iter_b];
		show_all(iter, iter_end);
#ifdef _DEBUG
		out << "-------------------\n";
#endif
		for (;iter != iter_end; ++iter)
		{
			for (auto win_max_iter = win_max_iter_b;
				(win_max_iter != win_max_index + N)&& winmin_max <= win[*win_max_iter] + undefined[*win_max_iter];++win_max_iter)
			{
#ifdef _DEBUG
				out << *win_max_iter << ' ';
#endif
				winmin_max = std::max(winmin_max, win[*win_max_iter]);
				graph[*iter].push_back(*win_max_iter); ++indegrees[*win_max_iter];
			}
		}
#ifdef _DEBUG
		out << "\n-------------------\n";
#endif
	}
	
	show_all(indegrees, indegrees + N);

	//???????????????????????????

	bool is_double = false;
	{
		int32_t count = 0;
		std::queue<int32_t> que;
		for (int32_t i = 0; i < N; ++i)
		{
			if (indegrees[i] <= 0) { que.push(i); }
		}
#ifdef _DEBUG
			out << endl << "quesize" << que.size() << endl;
#endif
		while (!que.empty())
		{
			if (que.size() >= 2) { is_double = true; }
			auto v = que.front(); que.pop();
#ifdef _DEBUG
			out << "v:" << v << endl;
#endif
			tp_sorted_index[v] = count++;
			for (auto& e : graph[v]) {
				if ((--indegrees[e]) <= 0) { que.push(e); }
#ifdef _DEBUG
				out <<e << " " << indegrees[e]<<endl;
#endif
			}
#ifdef _DEBUG
			out << "quesize" << que.size() << endl;
#endif
		}
	}
#ifdef _DEBUG
	out << "-------------------\n";
#endif

	for (int32_t i = 0; i < N; ++i)
	{
		out << tp_sorted_index[i]+1<<endl;
	}
	out << (is_double ? 1 : 0) << endl;

	return 0;
}
#endif

Compiler output:
a.cc: In function 'int main()':
a.cc:80:53: error: unable to find numeric literal operator 'operator""i32'
   80 |         std::iota(win_max_index, win_max_index + N, 0i32);
      |                                                     ^~~~
a.cc:84:53: error: unable to find numeric literal operator 'operator""i32'
   84 |         std::iota(win_min_index, win_min_index + N, 0i32);
      |                                                     ^~~~