Cod sursa(job #1596411)

Utilizator stefanxdanDanila Sergiu Stefan stefanxdan Data 10 februarie 2016 23:32:10
Problema Strazi Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <fstream>

using namespace std;
int a[7003];

int main()
{
    int n,m,x,y;
    ifstream fin("strazi.in");
    ofstream fout("strazi.out");
    fin>>n>>m;
    for(int i=1;i<=m;i++)
        {
            fin>>x>>y;
            if(x==y-1)
                {if(a[x]==0) n--;
                a[x]=1;
                }
        }
    fout<<n-1<<"\n";
    int i=1;
    while(i<=n)
    {
        if(a[i]==0) {fout<<i<<" "<<(i+1)<<"\n"; a[i]=1;}
        i++;
    }
    i=1;
    while(a[i]==1)
    {
        fout<<i<<" ";
        i++;
    }
    fout<<i;

    return 0;
}