답안 #1054346

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054346 2024-08-12T08:58:16 Z KebabuVaikis15 Palembang Bridges (APIO15_bridge) C++14
0 / 100
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN=100000;
long long k, n, suma=0, ats=LONG_MAX;
char a[MAXN], b[MAXN];
long long x[MAXN], y[MAXN];
vector<tuple<long long, long long, long long>> keliai;
long long kPtr=0, vPtr=-1, dPtr=0;
long long kKairej=0, kDesinej=0, dKairej=0, dDesinej;
bool kairej[MAXN];

//void tinkintKaire(long long kPos, long long dPos)
//{////////////////////////////////////////////////////////////
//    if (dPos<=get<0>(keliai[kPtr]))
//        kKairej++;
//    if (kPos>=get<0>(keliai[kPtr]))
//        kDesinej++;
//    while (kKairej<kDesinej)
//    {
//        long long pradPos=get<0>(keliai[kPtr]);
//        kPtr++;
//        while(kairej[get<2>(keliai[kPtr])])
//            kPtr++;
//        ats-=(pradPos-get<0>(keliai[kPtr]))*(kDesinej-kKairej);
//        if (get<1>(keliai[kPtr])==0)
//            kDesinej--;
//        else
//            kKairej++;
//    }
//}

void tinkintDesine(long long dPos)/////////////////////////////
{
    if (dPos<=get<0>(keliai[dPtr]))
        dKairej--;
    cout<<"Pradedam "<<dPtr<<endl;
    while (dKairej<dDesinej)
    {
        long long pradPos=get<0>(keliai[dPtr]);
        dPtr++;
        cout<<dPtr;
        while(kairej[get<2>(keliai[dPtr])])
        {
            cout<<", "<<dPtr;
            dPtr++;
        }
        cout<<endl;
        cout<<suma<<"->";
        suma-=2ll*(get<0>(keliai[dPtr])-pradPos)*(dDesinej-dKairej);
        cout<<suma<<endl;
        if (get<1>(keliai[dPtr])==0)
            dDesinej--;
        else
            dKairej++;
    }
}

int main()
{
    cin>>k>>n;
    for (int i=0; i<n; i++)
    {
        cin>>a[i]>>x[i]>>b[i]>>y[i];
        if (x[i]>y[i])
                swap(x[i], y[i]);
        suma+=y[i]-x[i];
        if (a[i]!=b[i])
        {
            suma++;
            keliai.push_back(make_tuple(x[i], 0, i));
            keliai.push_back(make_tuple(y[i], 1, i));
        }
    }
    keliai.push_back(make_tuple(0, 0, 0));
    sort(keliai.begin(), keliai.end());
    cout<<suma<<endl;
    for (auto i:keliai)
        cout<<get<0>(i)<<' '<<get<1>(i)<<' '<<get<2>(i)<<endl;
    for (int i=0; i<n; i++)
        if (a[i]!=b[i])
            suma+=2ll*(x[i]-get<0>(keliai[0]));
    cout<<suma<<endl;
    ats=suma;
    dDesinej=keliai.size()/2;
    tinkintDesine(LONG_MAX);
    if (k==1)
    {
        cout<<suma<<endl;
        return 0;
    }
    while (vPtr!=2*n)
    {
        vPtr++;



//        tinkintKaire(0); //////////////
        tinkintDesine(0); ////////////////'
    }
    cout<<ats<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -