122642024-12-10 20:24:10feheristvanMekk Mester munkái (50 pont)cpp17Runtime error 7/502ms568 KiB
#include <iostream>
#include <fstream>

using namespace std;

struct elem{

    int kezd, veg, index;

};

void be(int &n, int &h, elem a[])
{
   // ifstream fin("szoveg.in");
    cin >> n >> h;
    for(int i=0;i<n;i++)
    {
        cin >> a[i].kezd >> a[i].veg;
        a[i].index=i+1;
    }
   // fin.close();
}
void buborek(int n, elem a[])
{
    int csere=n-1,akt_csere;
    do{
            akt_csere=0;
            for(int i=0;i<csere;i++)
            {
                if(a[i].veg>a[i+1].veg)
                {
                    swap(a[i],a[i+1]);
                    akt_csere=i;
                }

            }
          csere=akt_csere;

    }while(csere!=0);
}
void kiir(int n, elem a[])
{
   // ofstream fout("szoveg.out");
   int vege_apa=a[0].veg;
   int vege_fia = a[1].veg;
   int apa[100], fia[100], db_a = 1, db_f = 1;
   apa[0] = a[0].index;
   fia[0] = a[1].index;
   for(int i=2;i<n;i++)
   {
       if(a[i].kezd > vege_apa)
       {
            vege_apa=a[i].veg;
            apa[db_a] = a[i].index;
            db_a ++;
       } else if(a[i].kezd > vege_fia){
            vege_fia = a[i].veg;
            fia[db_f] = a[i].index;
            db_f ++;
       }
   }
   cout << db_a <<  " " << db_f << endl;
   for(int i = 0; i < db_a; i ++){
        cout << apa[i] << " ";
   }
   cout << endl;
   for(int i = 0; i < db_f; i ++){
        cout << fia[i] << " ";
   }
  // fout.close();

}
int main()
{
    int n,h;
    elem  a[100];
    be(n,h,a);
    buborek(n,a);
    kiir(n,a);
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base7/50
1Accepted0/01ms320 KiB
2Runtime error0/02ms568 KiB
3Accepted1/11ms320 KiB
4Accepted1/11ms320 KiB
5Wrong answer0/21ms360 KiB
6Wrong answer0/21ms320 KiB
7Accepted2/21ms320 KiB
8Wrong answer0/21ms320 KiB
9Accepted3/31ms320 KiB
10Runtime error0/11ms320 KiB
11Runtime error0/11ms320 KiB
12Runtime error0/21ms320 KiB
13Runtime error0/22ms500 KiB
14Runtime error0/22ms320 KiB
15Runtime error0/21ms320 KiB
16Runtime error0/31ms320 KiB
17Runtime error0/21ms508 KiB
18Runtime error0/21ms320 KiB
19Runtime error0/41ms320 KiB
20Runtime error0/41ms320 KiB
21Runtime error0/41ms320 KiB
22Runtime error0/41ms320 KiB
23Runtime error0/41ms320 KiB