Cod sursa(job #1059903)

Utilizator andreiiiiPopa Andrei andreiiii Data 17 decembrie 2013 10:40:28
Problema Grozavesti Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.08 kb
#include <algorithm>
#include <fstream>
#include <vector>

using namespace std;

const int N=302;

ifstream fin("grozavesti.in");
ofstream fout("grozavesti.out");

struct st
{
    char c;
    int x, y;
};

int a[N][N];
vector <st> sol;

st make_st(int x, int y)
{
    st aux;
    aux.x=x;
    aux.y=y;
    return aux;
}

int main()
{
    int n, i, j, mins, poz;
    fin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            fin>>a[i][j];
        }
    }
    for(i=1;i<n;i++)
    {
        mins=a[i][i];
        poz=i;
        for(j=i+1;j<=n;j++)
        {
            if(a[j][j]<mins)
            {
                mins=a[j][j];
                poz=j;
            }
        }
        if(a[poz][poz]<a[i][i])
        {
            swap(a[poz][poz], a[i][i]);
            sol.push_back(make_st(i, poz));
        }
    }
    fout<<2*sol.size()<<"\n";
    for(vector <st>::iterator it=sol.begin();it!=sol.end();it++)
    {
        fout<<"L "<<it->x<<" "<<it->y<<"\n";
        fout<<"C "<<it->x<<" "<<it->y<<"\n";
    }
}