QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#735567#8517. Interesting Pathsucup-team2526RE 0ms0kbC++201.3kb2024-11-11 20:45:292024-11-11 20:45:29

Judging History

你现在查看的是最新测评结果

  • [2024-11-11 20:45:29]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-11 20:45:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long

#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)

void err() {
	std::cout << std::endl;
}

template<class T, class... Ts>
void err(T arg, Ts &... args) {
	std::cout << fixed << setprecision(10) << arg << ' ';
	err(args...);
}

void GENSHEN_START() {
	int n,m;cin >> n >> m;
	vector <int> du(n + 5);
	vector <vector<pair<int,int>>> g(n + 5);
	for (int i = 1;i <= m;i++) {
		int u,v;cin >> u >> v;
		g[u].push_back({v,i});
		du[v]++;
	}
	queue <int> q;
	for (int i = 1;i <= n;i++) {
		if (du[i] == 0 && i != 1) {
			q.push(i);
		}
	}
	vector <int> vis(m + 5);
	while (!q.empty()) {
		auto now = q.front();q.pop();
		for (auto [v,p] : g[now]) {
			du[v]--;
			vis[p] = 1;
			if (du[v] == 0) q.push(v);
		}
	}
	vector <int> good(n + 5);
	vector <int> edge;
	vector <int> ans(n + 5);
	auto dfs = [&](auto self,int u) -> int{
		if (u == n) {
			return 1;
		}	
		good[u] = 1;
		for (auto [v,p] : g[u]) {
			if (vis[p]) continue;
			if (good[v]) {
				ans[u] += (ans[v] >= 1);
			}
			else {
				ans[u] += self(self,v);
			}
		}
	};
	cout << dfs(dfs,1);
}

signed main()
{
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int T = 1;
	//cin >> T;
	while (T--) GENSHEN_START();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

5 7
1 3
3 5
1 2
2 3
3 4
4 5
2 4

output:


result: