답안 #1054150

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

using namespace std;

int main()
{
    int k, n;
    cin >> k >> n;
    vector<pair<int, int>> v;
    vector<int> sarasas;
    set<int> s;
    int 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)
    {
        int ats=INT_MAX;
        for(int i=0; i<sarasas.size(); i++)
        {
            int 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);
        }
        cout << ats+priedas;
    }

    return 0;
}

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for(int i=0; i<sarasas.size(); i++)
      |                      ~^~~~~~~~~~~~~~~
bridge.cpp:45: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]
   45 |             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 1 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 -