Submission #1095186

# Submission time Handle Problem Language Result Execution time Memory
1095186 2024-10-01T13:51:59 Z dpsaveslives Palembang Bridges (APIO15_bridge) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int K,N; cin >> K >> N;
    if(K == 2){
        cout << 0 << "\n";
        return 0;
    }
    ll ans = 0;
    vector<int> vec;
    vector<pair<int,int>> dif;
    for(int i = 0;i<N;++i){
        char p1,p2; int s,t; cin >> p1 >> s >> p2 >> t;
        if(p1 != p2){
            vec.push_back(s); vec.push_back(t);
            dif.push_back({s,t});
        }
        else{
            ans += abs(s-t);
        }
    }
    sort(vec.begin(),vec.end());
    int med = vec[vec.size()/2];
    for(int i = 0;i<dif.size();++i){
        ans += abs(dif[i].f-med)+abs(dif[i].s-med)+1;
    }
    cout << ans << "\n";
    return 0;
}

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 0;i<dif.size();++i){
      |                   ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -