Skip to content

Instantly share code, notes, and snippets.

@edwardmjm
Created January 26, 2013 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwardmjm/4642582 to your computer and use it in GitHub Desktop.
Save edwardmjm/4642582 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define iter(v) __typeof((v).begin())
#define foreach(it, v) for (iter(v) it = (v).begin(); it != (v).end(); it++)
#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
ll sqr(ll x) {return x * x;}
template <class T> void checkmax(T &t, T x){if (x > t) t = x;}
template <class T> void checkmin(T &t, T x){if (x < t) t = x;}
template <class T> void _checkmax(T &t, T x){if (t == -1 || x > t) t = x;}
template <class T> void _checkmin(T &t, T x){if (t == -1 || x < t) t = x;}
ll power_mod(ll a, int b, int p) {
ll ret = 1;
for (; b; b >>= 1) {
if (b & 1) ret = ret * a % p;
a = a * a % p;
}
return ret;
}
int x, a, b;
void add(int d) {
x += d;
printf(" %d", x);
if (abs(d) == 2) b--;
if (abs(d) == 1) a--;
}
int main() {
freopen("jumping.in", "r", stdin);
freopen("jumping.out", "w", stdout);
int Tc;
scanf("%d", &Tc);
while (Tc--) {
int c;
scanf("%d%d%d", &a, &b, &c);
printf("0");
x = 0;
if (c % 3 == 0) {
rep(i, c / 3) add(3);
add(1);
rep (i, c / 3) add(-3);
add(1);
rep (i, c / 3) add(3);
} else if (c % 3 == 1) {
rep(i, c / 3 + 1) add(3);
add(-2);
rep(i, c / 3) add(-3);
add(1);
rep(i, c / 3) add(3);
add(2);
} else {
rep(i, c / 3 + 1) add(3);
add(-1);
rep(i, c / 3) add(-3);
add(-1);
rep(i, c / 3 + 1) add(3);
}
if (b & 1) {
while (a > 1) add(1);
int tmp = b / 2;
rep(i, tmp + 1) add(2);
add(-1);
rep(i, tmp) add(-2);
} else {
while (a > 1) add(1);
int tmp = b / 2;
rep(i, tmp) add(2);
add(1);
rep(i, tmp) add(-2);
}
puts("");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment