91032024-02-14 07:12:14PedriMekk Mester munkái (50 pont)cpp17Wrong answer 0/503ms4424 KiB
#include <iostream>
#include <fstream>

using namespace std;
int n ,k;

struct munak{
int kezd;
int veg;
int sorsz;
}a[10000];

int helyre(int elso, int utolso){
int i=elso, j=utolso, p=elso;
while(i<j){
    if(a[i].veg>a[j].veg){
        swap(a[i], a[j]);
        if(i==p){p=j;i++;}
        else {p=i;j--;}}
    else {
        if(p==i)j--;
        else i++;
    }
}
return p;
}

void gyors(int elso, int utolso){
if(elso<utolso){
    int k=helyre(elso, utolso);
    gyors(elso, k-1);
    gyors(k+1, utolso);
}
}


int main()
{
    ifstream f("be.in");
    f>>n>>k;
    for(int i=1;i<=n;i++){
        f>>a[i].kezd;
        f>>a[i].veg;
        a[i].sorsz=i;
    }
    gyors(1, n);
    /*for(int i=1;i<=n;i++){
        cout<<a[i].sorsz<<" "<<a[i].kezd<<" "<<a[i].veg<<endl;
    }*/
    int mveg=0, fveg=0;
    int mmu[10000], fmu[10000], m=0, fi=0;
    for(int i=1;i<=n;i++){
        if(mveg>fveg){
            if(mveg<a[i].kezd){
                m++;
                mmu[m]=a[i].sorsz;
                mveg=a[i].veg;
            }else if(fveg<a[i].kezd){
                fi++;
                fmu[fi]=a[i].sorsz;
                fveg=a[i].veg;
            }
        }else{
            if(fveg<a[i].kezd){
                fi++;
                fmu[fi]=a[i].sorsz;
                fveg=a[i].veg;
            }else if(mveg<a[i].kezd){
                m++;
                mmu[m]=a[i].sorsz;
                mveg=a[i].veg;
            }
        }
    }
    cout<<m<<" "<<fi<<endl;
    for(int i=1;i<=m;i++){
        cout<<mmu[i]<<" ";
    }
    cout<<endl;
    for(int i=1;i<=fi;i++){
        cout<<fmu[i]<<" ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms2020 KiB
2Wrong answer0/03ms2312 KiB
3Wrong answer0/13ms2672 KiB
4Wrong answer0/13ms2672 KiB
5Wrong answer0/23ms2804 KiB
6Wrong answer0/23ms2756 KiB
7Wrong answer0/23ms2884 KiB
8Wrong answer0/23ms3184 KiB
9Wrong answer0/33ms3472 KiB
10Wrong answer0/13ms3248 KiB
11Wrong answer0/13ms3500 KiB
12Wrong answer0/23ms3544 KiB
13Wrong answer0/23ms3896 KiB
14Wrong answer0/23ms3788 KiB
15Wrong answer0/23ms4080 KiB
16Wrong answer0/33ms3908 KiB
17Wrong answer0/23ms4132 KiB
18Wrong answer0/23ms4172 KiB
19Wrong answer0/43ms4424 KiB
20Wrong answer0/43ms4380 KiB
21Wrong answer0/43ms4416 KiB
22Wrong answer0/43ms4412 KiB
23Wrong answer0/43ms4380 KiB