Submission #400038

# Submission time Handle Problem Language Result Execution time Memory
400038 2021-05-07T08:33:50 Z MeGustaElArroz23 Palembang Bridges (APIO15_bridge) C++14
0 / 100
1 ms 332 KB
#include<bits/stdc++.h>
using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;

int main(){
    int k,n;
    cin >> k >> n;
    int sol=0;
    vii v;
    for (int i=n;i>0;i--){
        char a,b;
        int x,y;
        cin >> a >> x >> b >> y;
        if (a==b){
            sol+=abs(x-y);
            n--;
        }
        else v.push_back(pii{x,y});
    }
    if (k==1){
        vi a;
        for (pii x:v){
            a.push_back(x.first);
            a.push_back(x.second);
        }
        int median=v.size();
        auto it=a.begin();
        for (int i=1;i<median;i++) it++;
        nth_element(a.begin(),it,a.end());
        int piv=*it;
        for (pii x:v){
            sol++;
            sol+=abs(x.first-piv);
            sol+=abs(x.second-piv);
        }
        cout << sol<<'\n';
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -