108742024-04-17 12:46:01Leventusz09Particlescpp17Runtime error 0/1002.081s3564 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);
            }
        }
    }
    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--;
            }
        }
        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 << Ix[mTi]+1 << " " << Iy[mTi]+1 << endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/100
1Runtime error0/53ms1932 KiB
2Runtime error0/53ms2040 KiB
3Runtime error0/53ms2268 KiB
4Runtime error0/54ms2404 KiB
5Runtime error0/56ms2832 KiB
6Runtime error0/59ms2828 KiB
7Runtime error0/5446ms3020 KiB
8Runtime error0/5855ms3148 KiB
9Runtime error0/51.577s3220 KiB
10Time limit exceeded0/52.058s2508 KiB
11Time limit exceeded0/52.081s2700 KiB
12Time limit exceeded0/52.072s3044 KiB
13Time limit exceeded0/52.036s3252 KiB
14Time limit exceeded0/52.065s3424 KiB
15Time limit exceeded0/52.032s3464 KiB
16Time limit exceeded0/52.065s3404 KiB
17Time limit exceeded0/52.065s3564 KiB
18Time limit exceeded0/52.061s3404 KiB
19Time limit exceeded0/52.062s3448 KiB
20Time limit exceeded0/52.062s3444 KiB