108802024-04-17 13:59:24Leventusz09Particlescpp17Wrong answer 0/1002.099s3796 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;
    }*/
    /*Tx = vector<int>(0);
    Vx = vector<int>(0);
    Ty = vector<int>(0);
    Vy = vector<int>(0);*/
    int mTi = -1;
    for(int i=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;
        }
        if(mTi != -1){
            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;
     //   cout << "I.size()=" << I.size() << endl;
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/100
1Wrong answer0/53ms1680 KiB
2Wrong answer0/53ms1848 KiB
3Wrong answer0/53ms1936 KiB
4Wrong answer0/54ms2092 KiB
5Wrong answer0/514ms2488 KiB
6Wrong answer0/514ms2828 KiB
7Runtime error0/5446ms2696 KiB
8Runtime error0/5855ms3004 KiB
9Runtime error0/51.577s3304 KiB
10Time limit exceeded0/52.042s2508 KiB
11Time limit exceeded0/52.066s2900 KiB
12Time limit exceeded0/52.065s3000 KiB
13Time limit exceeded0/52.066s3228 KiB
14Time limit exceeded0/52.026s3256 KiB
15Time limit exceeded0/52.099s3348 KiB
16Time limit exceeded0/52.056s3572 KiB
17Time limit exceeded0/52.069s3796 KiB
18Time limit exceeded0/52.062s3572 KiB
19Time limit exceeded0/52.066s3656 KiB
20Time limit exceeded0/52.062s3712 KiB