Cod sursa(job #2979724)

Utilizator aaagabiTurbinca Gabriel aaagabi Data 15 februarie 2023 19:50:37
Problema Dame Scor 60
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.37 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("dame.in");
ofstream fout("dame.out");
int n;
pair <int ,int> x;
int main()
{
    fin>>n;

    if(n<=2)
    {
        fout<<"1\n";
        fout<<"1 1";
        return 0;
    }
    if(n==3)
    {
        fout<<"2\n";
        fout<<"1 1\n";
        fout<<"2 3\n";
        return 0;
    }
    fout<<n<<'\n';
    int k=n/2;
    if(k%3!=1)
    {
        x={2,1};
        fout<<x.first<<' '<<x.second<<'\n';
        for(int i=1;i<k;i++)
        {
            x.first+=2;
            x.second++;
            fout<<x.first<<' '<<x.second<<'\n';
        }
        x.first=1;
        x.second=k+1;
        for(int i=1;i<=n-k;i++)
        {
            fout<<x.first<<' '<<x.second<<'\n';
            x.first+=2;
            x.second++;
        }
    }
    else
    {
        x.first=1;
        x.second=k+1;
        for(int i=1;i<n-k;i++)
        {
            fout<<x.first<<' '<<x.second<<'\n';
            x.first+=2;
            x.second++;
        }
        if(n%2==1)
            fout<<n<<' '<<n<<'\n';
        x.first=n-1;
        x.second=k-2;
        for(int i=1;i<=k-2;i++)
        {
            fout<<x.first<<' '<<x.second<<'\n';
            x.first-=2;
            x.second--;
        }
        fout<<"2 "<<k-1<<'\n';
        fout<<"4 "<<k<<'\n';
    }
    return 0;
}