-
-
Save MinecraftFuns/650895cd40bb3e1eb2cb721d81da40dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define alive std::cout << "$LINE @" << __LINE__ << " ALIVE" << std::endl | |
#define watch(var) std::cout << "$ LINE @" << __LINE__ << " FUN @" << __FUNCTION__ \ | |
<< " VAR @" << (#var) << ": " << (var) << std::endl | |
using namespace std; | |
typedef int i32; | |
typedef unsigned int u32; | |
typedef long long i64; | |
typedef unsigned long long u64; | |
typedef double f64; | |
typedef long double f128; | |
typedef pair<int, int> pii; | |
template <typename Tp> | |
inline void read(Tp &x) | |
{ | |
x = 0; | |
bool neg = false; | |
char c = getchar(); | |
for (; !isdigit(c); c = getchar()) | |
{ | |
if (c == '-') | |
{ | |
neg = true; | |
} | |
} | |
for (; isdigit(c); c = getchar()) | |
{ | |
x = x * 10 + c - '0'; | |
} | |
if (neg) | |
{ | |
x = -x; | |
} | |
} | |
const int N = 80 + 5; | |
const int M = N * N; | |
int vec[3][M]; | |
inline void solve() | |
{ | |
int n, m; | |
read(n), read(m); | |
for (int i = 1; i < n; ++i) | |
{ | |
printf("%d %d %d\n", i, i + 1, i); | |
} | |
int cnt[3]; | |
memset(cnt, 0, sizeof(cnt)); | |
for (int i = n, cur = n % 3; i <= m; ++i, cur == 2 ? cur = 0 | |
: ++cur) | |
{ | |
vec[cur][++cnt[cur]] = i; | |
} | |
int sum = n * (n - 1) / 2, rest = (3 - sum % 3) % 3; | |
printf("%d %d %d\n", n, 1, vec[rest][cnt[rest]--]); | |
for (int i = 1, cur; i <= n - 2; ++i) | |
{ | |
cur = i; | |
for (int j = i + 2, max = n - (i == 1); j <= max; ++j) | |
{ | |
cur = (cur + j - 1) % 3; | |
if (cnt[cur] != 0) | |
{ | |
printf("%d %d %d\n", i, j, vec[cur][cnt[cur]--]); | |
} | |
} | |
} | |
} | |
int main() | |
{ | |
int T; | |
read(T); | |
for (int cas = 1; cas <= T; ++cas) | |
{ | |
printf("Case #%d:\n", cas); | |
solve(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment