Pagini recente » Cod sursa (job #1536048) | Cod sursa (job #2425481) | Autentificare | Cod sursa (job #1269664) | Cod sursa (job #2960445)
#include<bits/stdc++.h>
using namespace std;
ifstream fin("grozavesti.in");
ofstream fout("grozavesti.out");
#define cin fin
#define cout fout
#define N 200005
#define power 73
#define mod 66666013
#define oo 1e18
struct pereche
{
char tip;
int x, y;
};
int v[N], x, n, maxim, poz;
vector < pereche > rez;
int main()
{
cin >> n;
for(int i = 1 ; i <= n ; i++)
{
for(int j = 1 ; j <= n ; j++)
{
cin >> x;
if(i == j)v[i] = x;
}
}
while(n)
{
maxim = 0, poz = 1;
for(int i = 1 ; i <= n ; i++)
{
if(v[i] > maxim)
{
maxim = v[i];
poz = i;
}
}
if(poz != n)
{
swap(v[poz],v[n]);
rez.push_back({'C',poz,n});
rez.push_back({'L',n,poz});
}
n--;
}
cout << rez.size() << '\n';
for(auto t : rez)
{
cout << t.tip << " " << t.x << " " << t.y << '\n';
}
return 0;
}