답안 #363185

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363185 2021-02-05T09:04:28 Z buyolitsez Bubble Sort 2 (JOI18_bubblesort2) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

vector <int> countScans(vector<int> a, vector<int> x, vector<int> v) {
    int n = a.size(), q = x.size();
    vector <int> s(q);
    for(int f = 0; f < q; ++f) {
        a[x[f]] = v[f];
        int cnt = 0;
        vector<int> b = a;
        for(int i = 0; i < n; ++i) {
            bool flag = 0;
            for (int j = 0; j + 1 < n; ++j) {
                if (a[j] > a[j + 1]) {
                    swap(a[j], a[j + 1]);
                    flag = 1;
                }
            }
            cnt += (flag);
        }
        swap(a, b);
        s[f] = cnt;
    }
    return s;
}

signed main() {
    vector <int> ans = countScans({1, 2, 3, 4}, {0, 2}, {3, 1});
    for (auto u : ans) {
        cout << u << '\n';
    }
}

Compilation message

/tmp/ccERa6dZ.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccC5NNd2.o:bubblesort2.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status