update
This commit is contained in:
parent
f5b3a1cfcb
commit
6756c27bf9
@ -4,7 +4,7 @@
|
|||||||
using std::cin,std::cout;
|
using std::cin,std::cout;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
|
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -2,24 +2,27 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include<vector>
|
||||||
|
|
||||||
using std::cin,std::cout;
|
using std::cin,std::cout;
|
||||||
|
|
||||||
const int MAX_N {(int)2e5+5};
|
const int MAX_N {(int)2e5+5};
|
||||||
int n;
|
int n;
|
||||||
int next[MAX_N];
|
std::vector<int> next[MAX_N];
|
||||||
int inDegree[MAX_N];
|
int inDegree[MAX_N];
|
||||||
bool vis[MAX_N];
|
bool vis[MAX_N];
|
||||||
std::queue<int> q;
|
std::queue<int> q;
|
||||||
int ans;
|
int ans;
|
||||||
|
int input;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
|
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
|
||||||
|
|
||||||
std::cin>>n;
|
std::cin>>n;
|
||||||
for(int i=1;i<=n;i++){
|
for(int i=1;i<=n;i++){
|
||||||
cin>>next[i];
|
cin>>input;
|
||||||
inDegree[next[i]]++;
|
inDegree[input]++;
|
||||||
|
next[i].push_back(input);
|
||||||
}
|
}
|
||||||
const auto push_vis = [](int n){
|
const auto push_vis = [](int n){
|
||||||
q.push(n);
|
q.push(n);
|
||||||
@ -33,10 +36,16 @@ int main(){
|
|||||||
while(q.empty()==false){
|
while(q.empty()==false){
|
||||||
int front = q.front();
|
int front = q.front();
|
||||||
q.pop();
|
q.pop();
|
||||||
if(--inDegree[next[front]]<=0){
|
for(int i:next[front]){
|
||||||
push_vis(next[front]);
|
if(--inDegree[i]<=0){
|
||||||
|
push_vis(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
const auto dfs = [](){
|
||||||
|
|
||||||
|
};
|
||||||
for(int i=1;i<=n;i++){
|
for(int i=1;i<=n;i++){
|
||||||
if(vis[i])continue;
|
if(vis[i])continue;
|
||||||
int loop_size {0};
|
int loop_size {0};
|
||||||
|
Loading…
Reference in New Issue
Block a user