Cod sursa(job #2911404)

Utilizator TheNamelessOneCiociia Marius Andrei TheNamelessOne Data 29 iunie 2022 10:59:37
Problema Grozavesti Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <fstream>
#include <queue>

using namespace std;

ifstream cin ("grozavesti.in");
ofstream cout ("grozavesti.out");

int x,v[300],n;
queue <int> Qx,Qy;
queue <char> Qlc;

void pushereala (int i, int j, char ch)
{
    Qx.push(i);
    Qy.push(j);
    Qlc.push(ch);
}

void coutereala ()
{
    cout<<Qlc.front()<<" "<<Qx.front()<<" "<<Qy.front()<<"\n";
    Qlc.pop();
    Qx.pop();
    Qy.pop();
}

bool ieGoale (){
    if (Qlc.empty() || Qx.empty() || Qy.empty()) return true;
    else return false;
}

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;
        }
    for (int i=1; i<=n; ++i)
        for (int j=i+1; j<=n; ++j)
            if (v[j]<v[i]){
                pushereala(i,j,'L');
                pushereala(i,j,'C');
            }

    cout<<Qlc.size()<<"\n";
    while (!ieGoale())
        coutereala();

    return 0;
}