style: format code

This commit is contained in:
yanglbme
2019-08-21 10:10:08 +08:00
parent abc0d365de
commit 69ddc9fc52
101 changed files with 3154 additions and 2984 deletions

View File

@@ -2,7 +2,6 @@
#include <list>
#include <stack>
#define WHITE 0
#define GREY 1
#define BLACK 2
@@ -12,23 +11,27 @@ using namespace std;
int checked[999] = {WHITE};
void dfs(const list<int> lista[], int start) {
void dfs(const list<int> lista[], int start)
{
stack<int> stack;
int checked[999] = {WHITE};
stack.push(start);
checked[start] = GREY;
while(!stack.empty()) {
while (!stack.empty())
{
int act = stack.top();
stack.pop();
if(checked[act] == GREY) {
if (checked[act] == GREY)
{
cout << act << ' ';
for(auto it = lista[act].begin(); it != lista[act].end(); ++it) {
for (auto it = lista[act].begin(); it != lista[act].end(); ++it)
{
stack.push(*it);
if(checked[*it] != BLACK)
if (checked[*it] != BLACK)
checked[*it] = GREY;
}
checked[act] = BLACK; //nodo controllato
@@ -36,18 +39,19 @@ void dfs(const list<int> lista[], int start) {
}
}
int main() {
int u, w;
int n;
cin >> n;
list<int> lista[INF];
for(int i = 0; i < n; ++i) {
cin >> u >> w;
lista[u].push_back(w);
}
int main()
{
int u, w;
int n;
cin >> n;
list<int> lista[INF];
for (int i = 0; i < n; ++i)
{
cin >> u >> w;
lista[u].push_back(w);
}
dfs(lista, 0);
dfs(lista, 0);
return 0;
return 0;
}