Submission #1097836

# Submission time Handle Problem Language Result Execution time Memory
1097836 2024-10-08T10:04:40 Z michified Bubble Sort 2 (JOI18_bubblesort2) C++17
0 / 100
9000 ms 856 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++) {
            vector<int> tmp = a;
            tmp[x[i]] = v[i];
            int passes = 0;
            bool finished;
            for (int i = 0; i < a.size(); i++) {
                finished = true;
                for (int j = 1; j < a.size(); j++) {
                    if (tmp[j - 1] > tmp[j]) {
                        swap(tmp[j - 1], tmp[j]);
                        finished = false;
                    }
                }
                if (not finished) passes++;
                else break;
            }
            ans.push_back(passes);
        }
        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:27:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |                 for (int j = 1; j < a.size(); j++) {
      |                                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9002 ms 856 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -