답안 #1097840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097840 2024-10-08T10:08:19 Z michified Bubble Sort 2 (JOI18_bubblesort2) C++17
17 / 100
9000 ms 860 KB
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define lid id * 2 + 1
#define rid id * 2 + 2
#define lmn LLONG_MIN
#define lmx LLONG_MAX
#define imn INT_MIN
#define imx INT_MAX
using namespace std;
const ll mod = 1e9 + 7;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag, tree_order_statistics_node_update> 

vector<int> countScans(vector<int> a, vector<int> x, vector<int> v) {
        vector<int> ans;
        for (int i = 0; i < x.size(); i++) {
            a[x[i]] = v[i];
            vector<int> tmp = a;
            int passes = 0;
            bool finished;
            for (int i = 0; i < a.size(); i++) {
                finished = true;
                passes++;
                for (int j = 1; j < a.size(); j++) {
                    if (tmp[j - 1] > tmp[j]) {
                        swap(tmp[j - 1], tmp[j]);
                        finished = false;
                    }
                }
                if (finished) break;
            }
            ans.push_back(passes - 1);
        }
        return ans;
    }

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:20:27: 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 < x.size(); i++) {
      |                         ~~^~~~~~~~~~
bubblesort2.cpp:25:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             for (int i = 0; i < a.size(); i++) {
      |                             ~~^~~~~~~~~~
bubblesort2.cpp:28:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                 for (int j = 1; j < a.size(); j++) {
      |                                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 348 KB Output is correct
2 Correct 474 ms 344 KB Output is correct
3 Correct 6586 ms 524 KB Output is correct
4 Correct 6540 ms 344 KB Output is correct
5 Correct 2800 ms 512 KB Output is correct
6 Correct 376 ms 528 KB Output is correct
7 Correct 988 ms 344 KB Output is correct
8 Correct 1570 ms 596 KB Output is correct
9 Correct 2782 ms 520 KB Output is correct
10 Correct 3071 ms 764 KB Output is correct
11 Correct 3111 ms 344 KB Output is correct
12 Correct 3068 ms 520 KB Output is correct
13 Correct 3071 ms 524 KB Output is correct
14 Correct 3129 ms 344 KB Output is correct
15 Correct 3141 ms 344 KB Output is correct
16 Correct 3065 ms 348 KB Output is correct
17 Correct 3075 ms 504 KB Output is correct
18 Correct 3040 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 348 KB Output is correct
2 Correct 474 ms 344 KB Output is correct
3 Correct 6586 ms 524 KB Output is correct
4 Correct 6540 ms 344 KB Output is correct
5 Correct 2800 ms 512 KB Output is correct
6 Correct 376 ms 528 KB Output is correct
7 Correct 988 ms 344 KB Output is correct
8 Correct 1570 ms 596 KB Output is correct
9 Correct 2782 ms 520 KB Output is correct
10 Correct 3071 ms 764 KB Output is correct
11 Correct 3111 ms 344 KB Output is correct
12 Correct 3068 ms 520 KB Output is correct
13 Correct 3071 ms 524 KB Output is correct
14 Correct 3129 ms 344 KB Output is correct
15 Correct 3141 ms 344 KB Output is correct
16 Correct 3065 ms 348 KB Output is correct
17 Correct 3075 ms 504 KB Output is correct
18 Correct 3040 ms 348 KB Output is correct
19 Execution timed out 9061 ms 772 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 9056 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 348 KB Output is correct
2 Correct 474 ms 344 KB Output is correct
3 Correct 6586 ms 524 KB Output is correct
4 Correct 6540 ms 344 KB Output is correct
5 Correct 2800 ms 512 KB Output is correct
6 Correct 376 ms 528 KB Output is correct
7 Correct 988 ms 344 KB Output is correct
8 Correct 1570 ms 596 KB Output is correct
9 Correct 2782 ms 520 KB Output is correct
10 Correct 3071 ms 764 KB Output is correct
11 Correct 3111 ms 344 KB Output is correct
12 Correct 3068 ms 520 KB Output is correct
13 Correct 3071 ms 524 KB Output is correct
14 Correct 3129 ms 344 KB Output is correct
15 Correct 3141 ms 344 KB Output is correct
16 Correct 3065 ms 348 KB Output is correct
17 Correct 3075 ms 504 KB Output is correct
18 Correct 3040 ms 348 KB Output is correct
19 Execution timed out 9061 ms 772 KB Time limit exceeded
20 Halted 0 ms 0 KB -