답안 #530066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
530066 2022-02-24T13:36:19 Z Servus2022 전선 연결 (IOI17_wiring) C++14
0 / 100
1 ms 204 KB
#include "wiring.h"
#include <bits/stdc++.h>
#include <cassert>
#include <cstdio>

using namespace std;

vector < pair <int,int> > v;
int nr[200005];
long long sum;
void cupleaza (int poz)
{
    int minim = 1e9+1;
    int unde=0,j;
    for (j=0;j<v.size();j++)
    {
        if (v[poz].second!=v[j].second)
        {
            if (abs(v[poz].first-v[j].first)<minim)
            {
                minim = abs(v[poz].first-v[j].first);
                unde = j;
            }
        }
    }
    sum=sum+minim;
    nr[unde]++;
    nr[poz]++;
}
long long min_total_length(std::vector<int> r, std::vector<int> b) {
    int i;
    sum=0;
    v.clear();
    for (i=0;i<r.size();i++)
    {
        v.push_back({r[i],0});
    }
    for (i=0;i<b.size();i++)
    {
        v.push_back({b[i],1});
    }
    sort (v.begin(),v.end());
    for (i=0;i<v.size();i++)
    {
        if (nr[i]==0)
        {
            cupleaza(i);
        }
    }
    return sum;
}
#ifdef HOME
int main() {
	int n, m;
	assert(2 == scanf("%d %d", &n, &m));

	vector<int> r(n), b(m);
	for(int i = 0; i < n; i++)
		assert(1 == scanf("%d", &r[i]));
	for(int i = 0; i < m; i++)
		assert(1 == scanf("%d", &b[i]));

	long long res = min_total_length(r, b);
	printf("%lld\n", res);

	return 0;
}

#endif // HOME

Compilation message

wiring.cpp: In function 'void cupleaza(int)':
wiring.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (j=0;j<v.size();j++)
      |              ~^~~~~~~~~
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (i=0;i<r.size();i++)
      |              ~^~~~~~~~~
wiring.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (i=0;i<b.size();i++)
      |              ~^~~~~~~~~
wiring.cpp:43:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (i=0;i<v.size();i++)
      |              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB 3rd lines differ - on the 1st token, expected: '25859', found: '41560'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '904', found: '946'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB 3rd lines differ - on the 1st token, expected: '316', found: '356'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB 3rd lines differ - on the 1st token, expected: '27', found: '29'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB 3rd lines differ - on the 1st token, expected: '25859', found: '41560'
2 Halted 0 ms 0 KB -