Submission #637322

#TimeUsernameProblemLanguageResultExecution timeMemory
637322boris_mihov전선 연결 (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include "wiring.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <set>

typedef long long llong;
const int MAXN = 100000 + 10;

long long min_total_length(std::vector <int> r, std::vector <int> b) 
{
    int ptr = 0;
    llong ans = 0;
    if (b.size() < r.size()) std::swap(r, b);
    for (int i = 0 ; i < b.size() ; ++i)
    {
        if (b.size() - i == r.size() - ptr - 1 || (ptr + 1 != r.size() && abs(r[ptr] - b[i]) > abs(r[ptr + 1] - b[i]))) ++ptr;
        ans += abs(b[i] - r[ptr]);
    }

	return ans;
}#include "wiring.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <set>

typedef long long llong;
const int MAXN = 100000 + 10;

long long min_total_length(std::vector <int> r, std::vector <int> b) 
{
    int ptr = 0;
    llong ans = 0;
    if (b.size() < r.size()) std::swap(r, b);
    for (int i = 0 ; i < b.size() ; ++i)
    {
        if (b.size() - i == r.size() - ptr - 1 || (ptr + 1 != r.size() && abs(r[ptr] - b[i]) > abs(r[ptr + 1] - b[i]))) ++ptr;
        ans += abs(b[i] - r[ptr]);
    }

	return ans;
}

Compilation message (stderr)

wiring.cpp:23:2: error: stray '#' in program
   23 | }#include "wiring.h"
      |  ^
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:16:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i = 0 ; i < b.size() ; ++i)
      |                      ~~^~~~~~~~~~
wiring.cpp:18:60: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if (b.size() - i == r.size() - ptr - 1 || (ptr + 1 != r.size() && abs(r[ptr] - b[i]) > abs(r[ptr + 1] - b[i]))) ++ptr;
      |                                                    ~~~~~~~~^~~~~~~~~~~
wiring.cpp: At global scope:
wiring.cpp:23:3: error: 'include' does not name a type
   23 | }#include "wiring.h"
      |   ^~~~~~~
wiring.cpp:31:11: error: redefinition of 'const int MAXN'
   31 | const int MAXN = 100000 + 10;
      |           ^~~~
wiring.cpp:9:11: note: 'const int MAXN' previously defined here
    9 | const int MAXN = 100000 + 10;
      |           ^~~~
wiring.cpp:33:11: error: redefinition of 'long long int min_total_length(std::vector<int>, std::vector<int>)'
   33 | long long min_total_length(std::vector <int> r, std::vector <int> b)
      |           ^~~~~~~~~~~~~~~~
wiring.cpp:11:11: note: 'long long int min_total_length(std::vector<int>, std::vector<int>)' previously defined here
   11 | long long min_total_length(std::vector <int> r, std::vector <int> b)
      |           ^~~~~~~~~~~~~~~~
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:38:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0 ; i < b.size() ; ++i)
      |                      ~~^~~~~~~~~~
wiring.cpp:40:60: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if (b.size() - i == r.size() - ptr - 1 || (ptr + 1 != r.size() && abs(r[ptr] - b[i]) > abs(r[ptr + 1] - b[i]))) ++ptr;
      |                                                    ~~~~~~~~^~~~~~~~~~~