Submission #1305747

#TimeUsernameProblemLanguageResultExecution timeMemory
1305747DJ035보도블록 (KOI11_block)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> #define sanic ios_base::sync_with_stdio(0) #define x first #define y second #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using pi = pair<int, int>; const ll MEM = 3023; const ll MOD = 998244353; const ll INF = 9e18; ll gcd(ll n, ll m) { if (n % m) return gcd(m, n % m); return m; } void typeprint(ll x1, ll y1, ll dr) { if ((x1 + y1) % 2) { if (dr == 1) { cout << x1 << ' ' << y1 << ' ' << 1 << '\n'; cout << x1 << ' ' << y1 << ' ' << 0 << '\n'; } else { cout << x1 << ' ' << y1 << ' ' << 0 << '\n'; cout << x1 << ' ' << y1 << ' ' << 1 << '\n'; } } else { if (dr == 2) { cout << x1 << ' ' << y1 << ' ' << 1 << '\n'; cout << x1 << ' ' << y1 << ' ' << 0 << '\n'; } else { cout << x1 << ' ' << y1 << ' ' << 0 << '\n'; cout << x1 << ' ' << y1 << ' ' << 1 << '\n'; } } } ll n, m; int main() { sanic; cin.tie(0); cout.tie(0); cin >> n >> m; if (n % 2 && m % 2) { cout << 2 * n * m << '\n'; ll x1 = 1, y1 = 2; while (y1 < m) { if (y1 % 2) typeprint(x1, y1, 3); else { cout << x1 << ' ' << y1 << ' ' << 0 << '\n'; cout << x1 + 1 << ' ' << y1 << ' ' << 0 << '\n'; cout << x1 << ' ' << y1 << ' ' << 1 << '\n'; } y1++; } typeprint(x1, y1, 0); x1++; typeprint(x1, y1, 0); x1++; typeprint(x1, y1, 0); y1--; cout << x1 << ' ' << y1 << ' ' << 1 << '\n'; cout << x1 - 1 << ' ' << y1 << ' ' << 1 << '\n'; cout << x1 << ' ' << y1 << ' ' << 0 << '\n'; y1--; while (y1 > 1) { if (y1 % 2) { typeprint(x1, y1, 2); typeprint(x1 - 1, y1, 1); } else { cout << x1 - 1 << ' ' << y1 << ' ' << 1 << '\n'; cout << x1 << ' ' << y1 << ' ' << 1 << '\n'; cout << x1 << ' ' << y1 << ' ' << 0 << '\n'; } y1--; } if (n > 3) y1++; while (1) { if (n == 3) break; x1++; if (x1 == n) break; if (x1 % 2) { while (y1 > 2) { typeprint(x1, y1, 1); y1--; } typeprint(x1, y1, 0); } else { while (y1 < m) { typeprint(x1, y1, 3); y1++; } typeprint(x1, y1, 0); } } while (y1 > 1) { typeprint(x1, y1, 1); y1--; } while (x1 > 0) { typeprint(x1, y1, 2); x1--; } } else if (!(n % 2)) { cout << 2 * n * m << '\n'; ll x1 = 1, y1 = 2; while (1) { if (x1 == n) break; if (x1 % 2) { while (y1 < m) { typeprint(x1, y1, 3); y1++; } typeprint(x1, y1, 0); } else { while (y1 > 2) { typeprint(x1, y1, 1); y1--; } typeprint(x1, y1, 0); } x1++; } while (y1 > 0) { typeprint(x1, y1, 1); y1--; } y1++; x1--; while (x1 > 0) { typeprint(x1, y1, 2); x1--; } } else { cout << 2 * n * m << '\n'; ll x1 = 1, y1 = 1; while (1) { if (y1 == m) break; if (y1 % 2) { typeprint(x1, y1, 3); while (x1 < n) { x1++; typeprint(x1, y1, 0); } } else { typeprint(x1, y1, 3); while (x1 > 2) { x1--; typeprint(x1, y1, 2); } } y1++; } while (x1 > 1) { typeprint(x1, y1, 2); x1--; } while (y1 > 1) { typeprint(x1, y1, 1); y1--; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...