Submission #103593

#TimeUsernameProblemLanguageResultExecution timeMemory
103593luciocfSenior Postmen (BOI14_postmen)C++14
38 / 100
1092 ms13304 KiB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5+10;

typedef pair<int, int> pii;

bool markEdge[maxn], mark[maxn];

vector<pii> grafo[maxn];

stack<int> stk;

void dfs(int u)
{
	if (mark[u])
	{
		while (true)
		{
			int v = stk.top();
			stk.pop();

			mark[v] = 0;

			if (v == u)
			{
				printf("%d\n", v);
				break;
			}

			printf("%d ", v);
		}
	}

	for (auto v: grafo[u])
	{
		if (!markEdge[v.second])
		{
			mark[u] = 1;
			stk.push(u);
			markEdge[v.second] = 1;

			dfs(v.first);
		}
	}
}

int main(void)
{
	int n, m;
	scanf("%d %d", &n, &m);

	for (int i = 1; i <= m; i++)
	{
		int u, v;
		scanf("%d %d", &u, &v);

		grafo[u].push_back({v, i});
		grafo[v].push_back({u, i});
	}

	dfs(1);
}

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
postmen.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &u, &v);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...