Submission #1221796
Source Code Expand
#include <iterator>
#include <map>
#include <cstdio>
#include <functional>
#include <array>
#include <vector>
#include <utility>
struct Range
{
struct It { int num, step; int operator*(){return num;} void operator++(){num += step;} bool operator!=(const It& other){return num != other.num;} };
Range(int ee):b(0),e(ee){}
Range(int bb, int ee):b(bb), e(ee){}
It begin(){return {b, (b < e? 1: -1)};}
It end(){return {e, 0};}
int b, e;
};
template<typename T> inline T& UMAX(T& x, T y){if(x < y)x = y; return x;}
template<typename T> inline T& UMIN(T& x, T y){if(y < x)x = y; return x;}
template<typename T, typename... Args> struct ArithmiticPromotion { typedef decltype(T() + typename ArithmiticPromotion<Args...>::type()) type; };
template<typename T, typename U> struct ArithmiticPromotion<T, U> { typedef decltype(T() + U()) type; };
template<typename T> struct ArithmiticPromotion<T, T> { typedef T type; };
template<typename T> struct ArithmiticPromotion<T> { typedef T type; };
template<typename T, typename U> typename ArithmiticPromotion<T, U>::type MAX(T a, U b) { return a < b? b: a; }
template<typename T, typename... Args> typename ArithmiticPromotion<T, Args...>::type MAX(T a, Args... args) { return MAX(a, MAX(args...)); }
template<typename T, typename U> typename ArithmiticPromotion<T, U>::type MIN(T a, U b) { return a < b? a: b; }
template<typename T, typename... Args> typename ArithmiticPromotion<T, Args...>::type MIN(T a, Args... args) { return MIN(a, MIN(args...)); }
template<typename T> struct ScanfSpecifier{};
#define DEF(T,V) template<> struct ScanfSpecifier<T>{static constexpr const char* value = V;};
DEF(char*,"%s")DEF(int,"%d")DEF(double,"%lf")DEF(float,"%f")DEF(char,"%c")DEF(const char*,"%s")DEF(unsigned long,"%lu")DEF(unsigned int, "%u")
#ifdef _MSC_VER
DEF(long long int,"%I64d")
#else
DEF(long long int,"%lld")
#endif
#undef DEF
template<typename T> int RD(T& arg){return std::scanf(ScanfSpecifier<T>::value, &arg);}
template<int S> int RD(char (&arg)[S]){return std::scanf("%s", arg);}
int RD(char* arg){return std::scanf("%s", arg);}
template<> int RD<char>(char& arg){return std::scanf(" %c", &arg);}
template<typename T, typename... Args> int RD(T& arg1, Args&... args) {return RD(arg1) + RD(args...);}
template<typename T> T RD(){T ret; RD(ret); return ret;}
template<typename It> void RDV(It begin, It end) { while(begin != end) RD(*begin++); }
template<typename C> void RDV(C& c) {RDV(std::begin(c), std::end(c));}
template<typename T> void WT(T arg) {std::printf(ScanfSpecifier<T>::value, arg); }
template<typename T, typename U> void WT(std::pair<T, U> arg) {std::printf("("); WT(arg.first); std::printf(", "); WT(arg.second); std::printf(")");}
template<typename... Args> void WT(Args... args) { int alc = 0; int dummy[] = {((alc++? std::printf(" "): 0), WT(args), 0)...}; }
template<typename... Args> void WTL(Args... args) { WT(args...); std::printf("\n"); }
template<typename It> void WTV(It begin, It end) { int alc = 0; while(begin != end) (alc++? std::printf(" "): 0), WT(*begin++); }
template<typename C> void WTV(const C& c) {WTV(std::begin(c), std::end(c));}
template<typename It> void WTVL(It begin, It end) { WTV(begin, end); std::printf("\n"); }
template<typename C> void WTVL(const C& c) {WTVL(std::begin(c), std::end(c));}
#define _M_VARGS_NUM_IMPL(_1, _2, _3, _4, _5, _6, N, ...) N
#define _M_VARGS_NUM(...) _M_VARGS_NUM_IMPL(__VA_ARGS__, 6, 5, 4, 3, 2, 1)
#define _W1(_1) (#_1[0] == '"' || #_1[0] == '\''? WT("", _1, ""): WT('[', #_1, '=', _1, ']'))
#define _W2(_1, _2) (_W1(_1), _W1(_2))
#define _W3(_1, _2, _3) (_W1(_1), _W2(_2, _3))
#define _W4(_1, _2, _3, _4) (_W1(_1), _W3(_2, _3, _4))
#define _W5(_1, _2, _3, _4, _5) (_W1(_1), _W4(_2, _3, _4, _5))
#define _WW_IMPL2(num, ...) _W ## num(__VA_ARGS__)
#define _WW_IMPL(num, ...) _WW_IMPL2(num, __VA_ARGS__)
#define WW(...) (std::printf("(%03d) ", __LINE__), _WW_IMPL(_M_VARGS_NUM(__VA_ARGS__), __VA_ARGS__), WTL(""))
//alias
//RD[L],RDV[L],WT[L],WTV[L] for i/o
using RG = Range;
//template
#include <vector>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long int ll;
const int SIZE = 100009;
vector<int> adj[SIZE];
bool pass[SIZE];
vector<int> ans;
void dfs(int u)
{
pass[u] = true;
for(int to: adj[u])
if(!pass[to])
{
dfs(to);
ans.push_back(to);
break;
}
}
int main()
{
int N, M;
RD(N, M);
while(M--)
{
int u, v;
RD(u, v);
adj[u].push_back(v);
adj[v].push_back(u);
}
ans.push_back(1);
dfs(1);
reverse(ans.begin(), ans.end());
dfs(1);
WTL(ans.size());
WTVL(ans);
}
Submission Info
Submission Time |
|
Task |
B - Hamiltonish Path |
User |
bigINnnner |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
4945 Byte |
Status |
WA |
Exec Time |
53 ms |
Memory |
9720 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
All |
sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
2 ms |
2560 KB |
sample_02.txt |
WA |
2 ms |
2560 KB |
sample_03.txt |
WA |
2 ms |
2560 KB |
subtask_1_01.txt |
WA |
33 ms |
4864 KB |
subtask_1_02.txt |
WA |
10 ms |
3072 KB |
subtask_1_03.txt |
WA |
30 ms |
4864 KB |
subtask_1_04.txt |
WA |
35 ms |
4736 KB |
subtask_1_05.txt |
WA |
35 ms |
4736 KB |
subtask_1_06.txt |
WA |
36 ms |
4864 KB |
subtask_1_07.txt |
WA |
37 ms |
5888 KB |
subtask_1_08.txt |
WA |
37 ms |
5760 KB |
subtask_1_09.txt |
WA |
53 ms |
9720 KB |
subtask_1_10.txt |
AC |
11 ms |
3328 KB |
subtask_1_11.txt |
AC |
13 ms |
3328 KB |
subtask_1_12.txt |
AC |
2 ms |
2560 KB |
subtask_1_13.txt |
WA |
2 ms |
2560 KB |