108722024-04-17 12:41:49Leventusz09Particlescpp17Runtime error 0/1002.078s4024 KiB
#include <bits/stdc++.h>



using namespace std;

int main(){
    int N, L, K;
    cin >> N;
    cin >> L;
    cin >> K;

    vector<int> Vx(N);
    vector<int> Vy(N);
    vector<int> Tx(N);
    vector<int> Ty(N);

    vector<float> I(0); // ütközés dátumok
    float t = 0;
    vector<int> Ix(0);  // ütköző indexek
    vector<int> Iy(0);

    for(int i=0; i<N; i++){
        cin >> Tx[i];
        cin >> Vx[i];
    }
    for(int i=0; i<N; i++){
        cin >> Ty[i];
        cin >> Vy[i];

        for(int j=0; j<N; j++){
            t = float(L + Vx[j]*Tx[j] + Vy[i]*Ty[i])/(Vx[j]+Vy[i]);
            if(0 < Vx[i] * (t - Tx[i]) && Vx[i] * (t-Tx[i]) < 100){
                I.push_back(float(t));
                Ix.push_back(j);
                Iy.push_back(i);
            }
        }
    }
    for(int i=0; i<I.size(); i++){
        cout << "p=" << Vx[Ix[i]] * (I[i] - Tx[Ix[i]]) << "; t=" << I[i] << " (" << Ix[i]+1 << ", " << Iy[i] + 1 << ")" << endl;
    }
    float mTi = -1;
    for(int i=0, l=0, j; i<K; i++){
        for(j=0; mTi!= -1 && j<I.size(); j++){
            if((Ix[j] == Ix[mTi] || Iy[j] == Iy[mTi]) && mTi != j){
                I.erase(I.begin() + j);
                Ix.erase(Ix.begin() + j);
                Iy.erase(Iy.begin() + j);
                j--;
                if(mTi > j) mTi--;
                //cout << "Deleted. (" << I.size() << ")"  << endl;
            }//else if(I[j] < (mTi==-1)?INT_MAX:I[mTi]) mTi = j;
        }
        I.erase(I.begin() + mTi);
        Ix.erase(Ix.begin() + mTi);
        Iy.erase(Iy.begin() + mTi);
        mTi = -1;

        for(j=0; j<I.size(); j++) if(I[j] < (mTi==-1?INT_MAX:I[mTi]) )  mTi = j;
        //cout << "mTi = " << mTi << endl;
        cout << Ix[mTi]+1 << " " << Iy[mTi]+1 << endl;
    }

}
SubtaskSumTestVerdictTimeMemory
subtask10/100
1Runtime error0/53ms2028 KiB
2Runtime error0/53ms2304 KiB
3Runtime error0/53ms2244 KiB
4Runtime error0/54ms2444 KiB
5Runtime error0/543ms2848 KiB
6Runtime error0/529ms3084 KiB
7Runtime error0/5448ms2980 KiB
8Runtime error0/5856ms3064 KiB
9Runtime error0/51.58s3432 KiB
10Time limit exceeded0/52.069s2528 KiB
11Time limit exceeded0/52.058s2480 KiB
12Time limit exceeded0/52.069s2700 KiB
13Time limit exceeded0/52.066s2928 KiB
14Time limit exceeded0/52.065s3224 KiB
15Time limit exceeded0/52.078s3516 KiB
16Time limit exceeded0/52.065s3676 KiB
17Time limit exceeded0/52.042s3768 KiB
18Time limit exceeded0/52.062s3784 KiB
19Time limit exceeded0/52.065s3808 KiB
20Time limit exceeded0/52.071s4024 KiB