Cod sursa(job #2979743)

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

using namespace std;
ifstream fin("dame.in");
ofstream fout("dame.out");
int n,t;
pair <int ,int> x;
vector <pair <int,int> > ans;
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};
        for(int i=1; i<=k; i++)
        {
            //fout<<x.first<<' '<<x.second<<'\n';
            ans.push_back(x);
            x.first+=2;
            x.second++;
        }
        x.first=1;
        x.second=k+1;
        for(int i=1; i<=n-k; i++)
        {
            //fout<<x.first<<' '<<x.second<<'\n';
            ans.push_back(x);
            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';
            ans.push_back(x);
            x.first+=2;
            x.second++;
        }
        if(n%6==3)
            ans.pop_back();
        x.first=2;
        x.second=2;
        for(int i=1;i<=k;i++)
        {
            //fout<<x.first<<' '<<x.second<<'\n';
            ans.push_back(x);
            x.first+=2;
            x.second++;
        }
        //fout<<"2 "<<k-1<<'\n';
        //fout<<"4 "<<k<<'\n';
    }
    fout<<ans.size()<<'\n';
    for(int i=0; i<ans.size(); i++)
        fout<<ans[i].first<<' '<<ans[i].second<<'\n';
return 0;
}