Submission #363313

# Submission time Handle Problem Language Result Execution time Memory
363313 2021-02-05T13:40:27 Z buyolitsez Bubble Sort 2 (JOI18_bubblesort2) C++17
0 / 100
9000 ms 524292 KB
#include "bubblesort2.h"
#include <bits/stdc++.h>

using namespace std;

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

std::vector<int> countScans(std::vector<int> a,std::vector<int> x,std::vector<int> v){
    int n = a.size(), q = x.size();
    vector <int> s(q, n - 1);
    vector<int> b = a;
    for(int f = 0; f < q; ++f) {
        a[x[f]] = v[f];
        b[x[f]] = v[f];
        int cnt = 0;
        vector <pair <int, int>> segs;
        for (int i = 0; i < n; ++i) {
            int last = i;
            for (int j = i + 1; j < n; ++j) {
                if (a[i] > a[j]) {
                    segs.emplace_back(last, j);
                    last = j;
                }
            }
        }
        int g = segs.size();
        vector <bool> used(g, 0);
        int ost = g;
        while (ost) {
            ++cnt;
            int last = -1;
            for (int i = 0; i < g; ++i) {
                if (used[i] || segs[i].first < last) {continue;}
                last = segs[i].second;
                --ost;
                used[i] = 1;
            }
        }
        s[f] = cnt;
        a = b;
    }
    return s;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 9058 ms 2556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9058 ms 2556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 911 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 9058 ms 2556 KB Time limit exceeded
2 Halted 0 ms 0 KB -