Submission #103590

# Submission time Handle Problem Language Result Execution time Memory
103590 2019-03-31T19:14:10 Z luciocf Senior Postmen (BOI14_postmen) C++17
0 / 100
13 ms 12032 KB
#include <bits/stdc++.h>
#define gc getchar

using namespace std;

const int maxn = 5e5+10;

typedef pair<int, int> pii;

bool markEdge[maxn], mark[maxn];

vector<pii> grafo[maxn];

vector<int> stk;

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

			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_back(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", &n, &m);

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

	dfs(1);
}

Compilation message

postmen.cpp: In function 'int main()':
postmen.cpp:53: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:58:8: 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:7: warning: 'u' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int u, v;
       ^
postmen.cpp:57:10: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int u, v;
          ^
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 12032 KB Some edges were not used
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 12032 KB Some edges were not used
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 12032 KB Some edges were not used
2 Halted 0 ms 0 KB -