#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")
#define eb emplace_back
typedef long long ll;
const ll ADD = 1000000;
std::vector<int> countScans(std::vector<int> aa,std::vector<int> xx,std::vector<int> vv){
vector <ll> a, x, v;
for (auto u : aa) {
a.eb(u);
}
for (int i = 0; i < xx.size(); ++i) {
x.eb(xx[i]);
v.eb(vv[i]);
}
int n = a.size(), q = x.size();
vector <int> s(q, n - 1);
for (int i = 0; i < n; ++i) {
a[i] = a[i] * ADD + i;
}
for(int f = 0; f < q; ++f) {
a[x[f]] = v[f] * ADD + x[f];
ll mx = 0;
for (int i = 0; i < n; ++i) {
ll cnt = 0;
for (int j = 0; j < i; ++j) {
if (a[j] > a[i]) {
++cnt;
}
}
mx = max(mx, cnt);
}
s[f] = mx;
}
return s;
}
Compilation message
bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for (int i = 0; i < xx.size(); ++i) {
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
364 KB |
Output is correct |
2 |
Correct |
298 ms |
432 KB |
Output is correct |
3 |
Correct |
4260 ms |
492 KB |
Output is correct |
4 |
Correct |
4210 ms |
492 KB |
Output is correct |
5 |
Correct |
4249 ms |
492 KB |
Output is correct |
6 |
Correct |
4216 ms |
492 KB |
Output is correct |
7 |
Correct |
4315 ms |
492 KB |
Output is correct |
8 |
Correct |
4192 ms |
492 KB |
Output is correct |
9 |
Correct |
4225 ms |
492 KB |
Output is correct |
10 |
Correct |
4262 ms |
492 KB |
Output is correct |
11 |
Correct |
4259 ms |
492 KB |
Output is correct |
12 |
Correct |
4249 ms |
512 KB |
Output is correct |
13 |
Correct |
4275 ms |
492 KB |
Output is correct |
14 |
Correct |
4258 ms |
492 KB |
Output is correct |
15 |
Correct |
4177 ms |
492 KB |
Output is correct |
16 |
Correct |
4244 ms |
492 KB |
Output is correct |
17 |
Correct |
4248 ms |
492 KB |
Output is correct |
18 |
Correct |
4244 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
364 KB |
Output is correct |
2 |
Correct |
298 ms |
432 KB |
Output is correct |
3 |
Correct |
4260 ms |
492 KB |
Output is correct |
4 |
Correct |
4210 ms |
492 KB |
Output is correct |
5 |
Correct |
4249 ms |
492 KB |
Output is correct |
6 |
Correct |
4216 ms |
492 KB |
Output is correct |
7 |
Correct |
4315 ms |
492 KB |
Output is correct |
8 |
Correct |
4192 ms |
492 KB |
Output is correct |
9 |
Correct |
4225 ms |
492 KB |
Output is correct |
10 |
Correct |
4262 ms |
492 KB |
Output is correct |
11 |
Correct |
4259 ms |
492 KB |
Output is correct |
12 |
Correct |
4249 ms |
512 KB |
Output is correct |
13 |
Correct |
4275 ms |
492 KB |
Output is correct |
14 |
Correct |
4258 ms |
492 KB |
Output is correct |
15 |
Correct |
4177 ms |
492 KB |
Output is correct |
16 |
Correct |
4244 ms |
492 KB |
Output is correct |
17 |
Correct |
4248 ms |
492 KB |
Output is correct |
18 |
Correct |
4244 ms |
492 KB |
Output is correct |
19 |
Execution timed out |
9067 ms |
748 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
9083 ms |
1004 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
364 KB |
Output is correct |
2 |
Correct |
298 ms |
432 KB |
Output is correct |
3 |
Correct |
4260 ms |
492 KB |
Output is correct |
4 |
Correct |
4210 ms |
492 KB |
Output is correct |
5 |
Correct |
4249 ms |
492 KB |
Output is correct |
6 |
Correct |
4216 ms |
492 KB |
Output is correct |
7 |
Correct |
4315 ms |
492 KB |
Output is correct |
8 |
Correct |
4192 ms |
492 KB |
Output is correct |
9 |
Correct |
4225 ms |
492 KB |
Output is correct |
10 |
Correct |
4262 ms |
492 KB |
Output is correct |
11 |
Correct |
4259 ms |
492 KB |
Output is correct |
12 |
Correct |
4249 ms |
512 KB |
Output is correct |
13 |
Correct |
4275 ms |
492 KB |
Output is correct |
14 |
Correct |
4258 ms |
492 KB |
Output is correct |
15 |
Correct |
4177 ms |
492 KB |
Output is correct |
16 |
Correct |
4244 ms |
492 KB |
Output is correct |
17 |
Correct |
4248 ms |
492 KB |
Output is correct |
18 |
Correct |
4244 ms |
492 KB |
Output is correct |
19 |
Execution timed out |
9067 ms |
748 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |