Pagini recente » Cod sursa (job #448403) | Cod sursa (job #1895005) | Cod sursa (job #2394649) | Cod sursa (job #1677500) | Cod sursa (job #2228249)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("grozavesti.in");
ofstream fout ("grozavesti.out");
const short NMAX = 305;
int a[NMAX][NMAX] , b[NMAX] , n;
struct T
{
char ch;
int lin , col;
};
T sol[2 * NMAX];
int main()
{
int x , dim = 0;
fin >> n;
for(int i = 1 ; i <= n ; i++)
for(int j = 1 ; j <= n ; j++)
{
fin >> x;
a[i][j] = x;
if(i == j)
b[i] = x;
}
sort(b + 1 , b + n + 1);
for(int i = 1 ; i <= n ; i++)
{
if(b[i] == a[i][i])
continue;
for(int j = i + 1 ; j <= n ; j++)
if(a[j][j] == b[i])
sol[++dim] = {'L' , i , j} , sol[++dim] = {'C' , i , j} , swap(a[i][i] , a[j][j]);
}
fout << dim << "\n";
for(int i = 1 ; i <= dim ; i++)
fout << sol[i] . ch << " " << sol[i] . lin << " " << sol[i] . col << "\n";
fin.close();
fout.close();
return 0;
}