답안 #1054155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054155 2024-08-12T07:05:46 Z Rojus Palembang Bridges (APIO15_bridge) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int k, n;
    cin >> k >> n;
    vector<pair<int, int>> v;
    vector<int> sarasas;
    set<int> s;
    long long priedas=0;
    for(int i=0; i<n; i++)
    {
        char cg, cd;
        int ig, id;
        cin >> cg >> ig >> cd >> id;
        if(cg!=cd)
        {
            priedas++;
            v.push_back({ig, id});
            if(s.find(ig)==s.end())
            {
                s.insert(ig);
                sarasas.push_back(ig);
            }
            if(s.find(id)==s.end())
            {
                s.insert(id);
                sarasas.push_back(id);
            }
        }
        else
        {
            priedas+=abs(ig-id);
        }
    }
    sort(sarasas.begin(), sarasas.end());
    if(k==1)
    {
        long long ats=INT_MAX;
        for(int i=0; i<sarasas.size(); i++)
        {
            long long sum=0;
            for(int j=0; j<v.size(); j++)
            {
                sum+=abs(v[j].first-sarasas[i])+abs(v[j].second-sarasas[i]);
            }
            ats=min(ats, sum);
        }
        ats+=priedas;
        cout << ats;
    }

    return 0;
}

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int i=0; i<sarasas.size(); i++)
      |                      ~^~~~~~~~~~~~~~~
bridge.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             for(int j=0; j<v.size(); j++)
      |                          ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 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 Incorrect 0 ms 348 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 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -