Submission #1498987


Source Code Expand

#include <bits/stdc++.h>
  
using namespace std;
  
//#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


const int MAX_N = 1e5+10;
vi es[MAX_N];
bool used[MAX_N];

int main(){
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		es[a].pb(b);
		es[b].pb(a);
	}
	deque<int> d;
	d.push_front(0);
	d.push_back(*es[0].begin());
	rep(i, 2) used[d[i]] = true;
	LINE;
	while(1) {
		dump(mp(d.front(), d.back()));
		bool update = false;
		for(auto& to : es[d.front()]) {
			if(!used[to]) {
				update = true;
				d.push_front(to);
				used[to] = true;
				break;
			}
		}
		for(auto& to : es[d.back()]) {
			if(!used[to]) {
				update = true;
				d.push_back(to);
				used[to] = true;
				break;
			}
		}
		if(!update) break;
	}
	cout << d.size() << endl;
	rep(i, d.size()) {
		cout << d[i]+1;
		if(i + 1 != d.size()) cout <<" ";
		else cout << endl;
	}

	return 0;
}

Submission Info

Submission Time
Task B - Hamiltonish Path
User T1610
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1945 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:55:6: error: ‘i’ was not declared in this scope
  rep(i, m) {
      ^
./Main.cpp:55:10: error: ‘rep’ was not declared in this scope
  rep(i, m) {
          ^