1368C - Even Picture

Editorial.

Time complexity: $O(n)$

Memory complexity: $O(1)$

Click to show code.


using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
int main(void)
{
    ios::sync_with_stdio(false), cin.tie(NULL);
    int n;
    cin >> n;
    vector<ii> points = {{1, 0}, {0, 1}, {1, 1}};
    cout << (n + 1) * 3 + 1 << endl;
    cout << 0 << " " << 0 << endl;
    for (int i = 0; i <= n; ++i)
        for (auto &[x, y] : points)
            cout << x++ << " " << y++ << endl;
    return 0;
}