답안 #893989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893989 2023-12-27T18:23:11 Z vovik Bubble Sort 2 (JOI18_bubblesort2) C++17
17 / 100
9000 ms 860 KB
#include <bits/stdc++.h>

std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V);


int get(std::vector<int> a) {
    for (int fl = 1, c = 0; !(fl = 0); ++c) {
        for (int i = 0; i + 1 < a.size(); ++i) if (a[i] > a[i + 1]) std::swap(a[i], a[i + 1]), fl = 1;
        if (!fl) return c;
    }
}

std::vector<int> countScans(std::vector<int> A, std::vector<int> X, std::vector<int> V) {
    int q = X.size();
    std::vector<int> answer(q);
    for (int j = 0; j < q; j++) {
        A[X[j]] = V[j];
        answer[j] = get(A);
    }
    return answer;
}


#ifdef __APPLE__
#include <cstdio>
#include <cstdlib>
#include <vector>

int readInt() {
    int i;
    if (scanf("%d", &i) != 1) {
        fprintf(stderr, "Error while reading input\n");
        exit(1);
    }
    return i;
}

int main() {
    int N, Q;
    N = readInt();
    Q = readInt();

    std::vector<int> A(N);
    for (int i = 0; i < N; i++)
        A[i] = readInt();

    std::vector<int> X(Q), V(Q);
    for (int j = 0; j < Q; j++) {
        X[j] = readInt();
        V[j] = readInt();
    }

    std::vector<int> res = countScans(A, X, V);

    for (int j = 0; j < int(res.size()); j++)
        printf("%d\n", res[j]);
}
#endif

Compilation message

bubblesort2.cpp: In function 'int get(std::vector<int>)':
bubblesort2.cpp:8:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |         for (int i = 0; i + 1 < a.size(); ++i) if (a[i] > a[i + 1]) std::swap(a[i], a[i + 1]), fl = 1;
      |                         ~~~~~~^~~~~~~~~~
bubblesort2.cpp:11:1: warning: control reaches end of non-void function [-Wreturn-type]
   11 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 348 KB Output is correct
2 Correct 609 ms 604 KB Output is correct
3 Correct 8316 ms 524 KB Output is correct
4 Correct 8605 ms 516 KB Output is correct
5 Correct 3799 ms 520 KB Output is correct
6 Correct 598 ms 520 KB Output is correct
7 Correct 1452 ms 520 KB Output is correct
8 Correct 2283 ms 596 KB Output is correct
9 Correct 3804 ms 516 KB Output is correct
10 Correct 6902 ms 512 KB Output is correct
11 Correct 6909 ms 512 KB Output is correct
12 Correct 6897 ms 528 KB Output is correct
13 Correct 6920 ms 512 KB Output is correct
14 Correct 6959 ms 512 KB Output is correct
15 Correct 7041 ms 516 KB Output is correct
16 Correct 6996 ms 512 KB Output is correct
17 Correct 6921 ms 512 KB Output is correct
18 Correct 6993 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 348 KB Output is correct
2 Correct 609 ms 604 KB Output is correct
3 Correct 8316 ms 524 KB Output is correct
4 Correct 8605 ms 516 KB Output is correct
5 Correct 3799 ms 520 KB Output is correct
6 Correct 598 ms 520 KB Output is correct
7 Correct 1452 ms 520 KB Output is correct
8 Correct 2283 ms 596 KB Output is correct
9 Correct 3804 ms 516 KB Output is correct
10 Correct 6902 ms 512 KB Output is correct
11 Correct 6909 ms 512 KB Output is correct
12 Correct 6897 ms 528 KB Output is correct
13 Correct 6920 ms 512 KB Output is correct
14 Correct 6959 ms 512 KB Output is correct
15 Correct 7041 ms 516 KB Output is correct
16 Correct 6996 ms 512 KB Output is correct
17 Correct 6921 ms 512 KB Output is correct
18 Correct 6993 ms 508 KB Output is correct
19 Execution timed out 9088 ms 796 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 9010 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 348 KB Output is correct
2 Correct 609 ms 604 KB Output is correct
3 Correct 8316 ms 524 KB Output is correct
4 Correct 8605 ms 516 KB Output is correct
5 Correct 3799 ms 520 KB Output is correct
6 Correct 598 ms 520 KB Output is correct
7 Correct 1452 ms 520 KB Output is correct
8 Correct 2283 ms 596 KB Output is correct
9 Correct 3804 ms 516 KB Output is correct
10 Correct 6902 ms 512 KB Output is correct
11 Correct 6909 ms 512 KB Output is correct
12 Correct 6897 ms 528 KB Output is correct
13 Correct 6920 ms 512 KB Output is correct
14 Correct 6959 ms 512 KB Output is correct
15 Correct 7041 ms 516 KB Output is correct
16 Correct 6996 ms 512 KB Output is correct
17 Correct 6921 ms 512 KB Output is correct
18 Correct 6993 ms 508 KB Output is correct
19 Execution timed out 9088 ms 796 KB Time limit exceeded
20 Halted 0 ms 0 KB -