E. Boboniu Walks on Graph
题目意思
给一个有向图,在图上走的时候,出度为 i 的边,只能走到边权大小为第 ci 小的边上面,问c数组有多少种,要每个点都满足:从这个点开始走都可以回到这个点。
每个点的入度都小于等于9
题解
都可以回到这个点,,但是每个点的出边只能有一条,所以n个点,入度都为1。
因为入度都是小于10的所以可以暴力枚举一下c数组,然后check。
怎么check? 只要按照枚举出来的 c 数组走,每个点的入度等于1就可以。
所以可以预处理一下,预处理入读为 i 的所有点走权值大小为 j 的时候,可以走到哪些点。
刚开始用的bitset,果断tle。改成哈希就好了。
#include<algorithm>
#include<iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <cstring>
#include <stack>
#include <map>
#include <bitset>
#include <set>
#include <unordered_set>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,ll> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef unsigned long long ull;
typedef unordered_set<int>::iterator sit;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void tempwj(