답안 #1067259

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067259 2024-08-20T13:33:58 Z Ignut Simurgh (IOI17_simurgh) C++17
컴파일 오류
0 ms 0 KB
// Ignut

#include <bits/stdc++.h>

using namespace std;
using ll = long long;


int count_common_roads(vector<int> r);

const int N = 555;

vector<int> g[N];

vector<int> MakeVector(vector<int> &vec, int l, int r) {
    vector<int> res;
    for (int i = l; i <= r; i ++) res.push_back(vec[i]);
    return res;
}

bool ans[N * N];

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
    for (int i = 0; i < u.size(); i ++) {
        g[u[i]].push_back(i);
        g[v[i]].push_back(i);
    }
    for (int v = 0; v < n; v ++) {
        int sz = g[v].size();
        int total = count_common_roads(MakeVector(g[v], 0, sz - 1));
        int l = -1;
        for (int j = 0; j < total; j ++) {
            int lo = l + 1, hi = sz - 1;
            // int prev_cnt = count_common_roads(MakeVector(g[v], l + 1, sz - 1));
            while (lo < hi) {
                int mid = lo + (hi - lo) / 2;
                int cnt = count_common_roads(MakeVector(g[v], l + 1, mid));
                if (cnt >= 1)
                    hi = mid;
                else
                    lo = mid + 1;
            }
            ans[g[v][lo]] = true;
            l = lo;
        }
    }
    vector<int> res;
    for (int i = 0; i < u.size(); i ++) if (ans[i]) res.push_back(i);
    return res;
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 0; i < u.size(); i ++) {
      |                     ~~^~~~~~~~~~
simurgh.cpp:48:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for (int i = 0; i < u.size(); i ++) if (ans[i]) res.push_back(i);
      |                     ~~^~~~~~~~~~
/usr/bin/ld: /tmp/cc6cfYYO.o: in function `find_roads(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)':
simurgh.cpp:(.text+0x217): undefined reference to `count_common_roads(std::vector<int, std::allocator<int> >)'
/usr/bin/ld: simurgh.cpp:(.text+0x30c): undefined reference to `count_common_roads(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status