Submission #421438

# Submission time Handle Problem Language Result Execution time Memory
421438 2021-06-09T07:22:08 Z 조영욱(#7654) Bubble Sort 2 (JOI18_bubblesort2) C++17
38 / 100
9000 ms 1484 KB
#include "bubblesort2.h"
#include <bits/stdc++.h>
using namespace std;

const int INF=1e9+1;
const int sz=16384;
int tree[sz];
vector<int> pr;

int sum(int i) {
    int ret=0;
    while (i>0) {
        ret+=tree[i];
        i-=(i&-i);
    }
    return ret;
}

void update(int i,int x) {
    while (i<sz) {
        tree[i]+=x;
        i+=(i&-i);
    }
}

vector<int> countScans(vector<int> A,vector<int> X,vector<int> V){
	int q=X.size();
	vector<int> ret(q);
	pr.push_back(-1);
	for(int i=0;i<A.size();i++) {
        pr.push_back(A[i]);
	}
	for(int i=0;i<q;i++) {
        pr.push_back(V[i]);
	}
	sort(pr.begin(),pr.end());
	pr.erase(unique(pr.begin(),pr.end()),pr.end());
	for(int i=0;i<A.size();i++) {
        A[i]=lower_bound(pr.begin(),pr.end(),A[i])-pr.begin();
	}
	for(int i=0;i<q;i++) {
        V[i]=lower_bound(pr.begin(),pr.end(),V[i])-pr.begin();
	}
	for (int j=0;j<q;j++) {
		A[X[j]]=V[j];
        int val=0;
        memset(tree,0,sizeof(tree));
        for(int i=0;i<A.size();i++) {
            val=max(val,sum(sz-1)-sum(A[i]));
            update(A[i],1);
        }
		ret[j]=val;
	}
	return ret;
}

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for(int i=0;i<A.size();i++) {
      |              ~^~~~~~~~~
bubblesort2.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i=0;i<A.size();i++) {
      |              ~^~~~~~~~~
bubblesort2.cpp:48:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for(int i=0;i<A.size();i++) {
      |                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 33 ms 372 KB Output is correct
3 Correct 173 ms 420 KB Output is correct
4 Correct 176 ms 420 KB Output is correct
5 Correct 204 ms 332 KB Output is correct
6 Correct 169 ms 420 KB Output is correct
7 Correct 178 ms 420 KB Output is correct
8 Correct 187 ms 424 KB Output is correct
9 Correct 172 ms 332 KB Output is correct
10 Correct 171 ms 416 KB Output is correct
11 Correct 172 ms 416 KB Output is correct
12 Correct 164 ms 428 KB Output is correct
13 Correct 181 ms 436 KB Output is correct
14 Correct 167 ms 420 KB Output is correct
15 Correct 164 ms 416 KB Output is correct
16 Correct 174 ms 420 KB Output is correct
17 Correct 164 ms 332 KB Output is correct
18 Correct 167 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 33 ms 372 KB Output is correct
3 Correct 173 ms 420 KB Output is correct
4 Correct 176 ms 420 KB Output is correct
5 Correct 204 ms 332 KB Output is correct
6 Correct 169 ms 420 KB Output is correct
7 Correct 178 ms 420 KB Output is correct
8 Correct 187 ms 424 KB Output is correct
9 Correct 172 ms 332 KB Output is correct
10 Correct 171 ms 416 KB Output is correct
11 Correct 172 ms 416 KB Output is correct
12 Correct 164 ms 428 KB Output is correct
13 Correct 181 ms 436 KB Output is correct
14 Correct 167 ms 420 KB Output is correct
15 Correct 164 ms 416 KB Output is correct
16 Correct 174 ms 420 KB Output is correct
17 Correct 164 ms 332 KB Output is correct
18 Correct 167 ms 416 KB Output is correct
19 Correct 2218 ms 644 KB Output is correct
20 Correct 2768 ms 880 KB Output is correct
21 Correct 2764 ms 876 KB Output is correct
22 Correct 2653 ms 876 KB Output is correct
23 Correct 2529 ms 840 KB Output is correct
24 Correct 2712 ms 844 KB Output is correct
25 Correct 2717 ms 844 KB Output is correct
26 Correct 2759 ms 844 KB Output is correct
27 Correct 2654 ms 844 KB Output is correct
28 Correct 2615 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2561 ms 844 KB Output is correct
2 Execution timed out 9091 ms 1484 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 33 ms 372 KB Output is correct
3 Correct 173 ms 420 KB Output is correct
4 Correct 176 ms 420 KB Output is correct
5 Correct 204 ms 332 KB Output is correct
6 Correct 169 ms 420 KB Output is correct
7 Correct 178 ms 420 KB Output is correct
8 Correct 187 ms 424 KB Output is correct
9 Correct 172 ms 332 KB Output is correct
10 Correct 171 ms 416 KB Output is correct
11 Correct 172 ms 416 KB Output is correct
12 Correct 164 ms 428 KB Output is correct
13 Correct 181 ms 436 KB Output is correct
14 Correct 167 ms 420 KB Output is correct
15 Correct 164 ms 416 KB Output is correct
16 Correct 174 ms 420 KB Output is correct
17 Correct 164 ms 332 KB Output is correct
18 Correct 167 ms 416 KB Output is correct
19 Correct 2218 ms 644 KB Output is correct
20 Correct 2768 ms 880 KB Output is correct
21 Correct 2764 ms 876 KB Output is correct
22 Correct 2653 ms 876 KB Output is correct
23 Correct 2529 ms 840 KB Output is correct
24 Correct 2712 ms 844 KB Output is correct
25 Correct 2717 ms 844 KB Output is correct
26 Correct 2759 ms 844 KB Output is correct
27 Correct 2654 ms 844 KB Output is correct
28 Correct 2615 ms 844 KB Output is correct
29 Correct 2561 ms 844 KB Output is correct
30 Execution timed out 9091 ms 1484 KB Time limit exceeded
31 Halted 0 ms 0 KB -