답안 #40183

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40183 2018-01-29T11:21:37 Z Abelyan Palembang Bridges (APIO15_bridge) C++14
0 / 100
5 ms 2180 KB
#include <bits/stdc++.h>
using namespace std;

#define fr first
#define sc second
#define _mp make_pair

vector <pair<int,int> > v;

int main()
{
    ios_base::sync_with_stdio(false);
    int k,n,ans=0;
    cin>>k>>n;
    for (int i=0;i<n;i++){
        char c1,c2;
        int a,b;
        cin>>c1>>a>>c2>>b;
        if (c1==c2){
            ans+=abs(b-a);
            continue;
        }
        v.push_back(_mp(a,b));
    }
    if (k==1){
        int mn=INT_MAX;
        for (int i=0;i<v.size();i++){
            int an1=0,an2=0;
            for (int j=0;j<v.size();j++){
                an1+=abs(v[i].fr-v[j].fr)+abs(v[i].fr-v[j].sc)+1;
            }
            for (int j=0;j<v.size();j++){
                an2+=abs(v[i].sc-v[j].fr)+abs(v[i].sc-v[j].sc)+1;
            }
            //cout<<an1<<" "<<an2<<endl;
            mn=min(mn,min(an1,an2));
        }
        if (mn==INT_MAX) mn=0;
        cout<<ans+mn<<endl;
    }
    else{

    }
    return 0;
}

Compilation message

bridge.cpp: In function 'int main()':
bridge.cpp:27:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i=0;i<v.size();i++){
                       ^
bridge.cpp:29:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<v.size();j++){
                           ^
bridge.cpp:32:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<v.size();j++){
                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Correct 4 ms 2180 KB Output is correct
4 Correct 4 ms 2180 KB Output is correct
5 Incorrect 2 ms 2180 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Correct 4 ms 2180 KB Output is correct
4 Correct 4 ms 2180 KB Output is correct
5 Incorrect 5 ms 2180 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2180 KB Output isn't correct
2 Halted 0 ms 0 KB -