답안 #1013624

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013624 2024-07-03T17:43:25 Z vjudge1 Bubble Sort 2 (JOI18_bubblesort2) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define mod 1000000007LL
#define inf 1e17
#define ll long long
using namespace std;

void printvec(vector<int> vec)
{
    for (auto &&e : vec)
    {
        cout << e << ' ';
    }
    cout << endl;
}

vector<int> countScans(vector<int>& a, vector<int>& x, vector<int>& v)
{
    vector<int> s;
    multiset<int> a_sorted;
    for (int i = 0; i < a.size(); i++)
    {
        a_sorted.insert(a[i]);
    }
    for (int j = 0; j < x.size(); j++)
    {
    a_sorted.erase(a_sorted.find(a[x[j]]));
    a_sorted.insert(v[j]);
    a[x[j]] = v[j];
    // for (auto& e:a_sorted) cout << e << ' ';
    // cout << endl;
    map<ll,ll> ind;
    ll i = 0;
    for (auto it = a_sorted.begin(); it != a_sorted.end(); it++)
    {
        ind[*it] = i;
        i++;
    }
    ll maxe = 0;
    for (int i = 0; i < a.size(); i++)
    {
        if(i > ind[a[i]])
        {
            maxe = max(maxe, i - ind[a[i]]);
        }
    }
    s.push_back(maxe);
    }
    return s;
}

// int main()
// {
//     vector<int> A = {1, 2, 3, 4};
//     vector<int> X = {0, 2};
//     vector<int> V = {3, 1};
//     vector<int> ans = countScans(A,X,V);
//     printvec(ans);
// }

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>&, std::vector<int>&, std::vector<int>&)':
bubblesort2.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
bubblesort2.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 j = 0; j < x.size(); j++)
      |                     ~~^~~~~~~~~~
bubblesort2.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i < a.size(); i++)
      |                     ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccUWS5L8.o: in function `main':
grader.cpp:(.text.startup+0x181): undefined reference to `countScans(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status