#include #include #include using namespace std; #define MAX (1<<13) // number of rows unordered_set diag[MAX]; unordered_set anti[MAX]; int main() { for (long long s=0; s::max(); unordered_set hori; for (long long c=0; c<=s; c++) { if ((c & (s-c))==0) { long long v = 0; while (hori.count(v) || diag[c].count(v) || anti[s-c].count(v)) { v++; } hori.insert(v); diag[c].insert(v); anti[s-c].insert(v); if (mi > v) { mi = v; } } } cout << s << ' ' << mi << endl; } return 0; }