Submission #363259

# Submission time Handle Problem Language Result Execution time Memory
363259 2021-02-05T11:52:24 Z NEvOl Bubble Sort 2 (JOI18_bubblesort2) C++14
Compilation error
0 ms 0 KB
#include "bubblesort2.h"

int get_cnt(vector<int> curr)
{
    int cnt = 0;
    int mn = curr[curr.size() - 1];
    for(int i = curr.size() - 2; -1 < i; i--)
    {
        if(mn < curr[i])
            cnt++;
        mn = min(mn, curr[i]);
    }    
    return cnt;
}

std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
	int Q=X.size();
	std::vector<int> answer(Q);
    vector<int> curr(A.size());
    for(int i = 0; i < A.size(); i++)
        curr[i] = A[i];
    int cnt = get_cnt(curr);

	for (int j=0;j<Q;j++) {
        curr[X[j]] = V[j];        
		answer[j]=get_cnt(curr);
	}
	return answer;
}

Compilation message

bubblesort2.cpp:3:13: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    3 | int get_cnt(vector<int> curr)
      |             ^~~~~~
      |             std::vector
In file included from /usr/include/c++/9/vector:67,
                 from bubblesort2.h:1,
                 from bubblesort2.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:386:11: note: 'std::vector' declared here
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
bubblesort2.cpp:3:20: error: expected primary-expression before 'int'
    3 | int get_cnt(vector<int> curr)
      |                    ^~~
bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:19:5: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   19 |     vector<int> curr(A.size());
      |     ^~~~~~
      |     std::vector
In file included from /usr/include/c++/9/vector:67,
                 from bubblesort2.h:1,
                 from bubblesort2.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:386:11: note: 'std::vector' declared here
  386 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
bubblesort2.cpp:19:12: error: expected primary-expression before 'int'
   19 |     vector<int> curr(A.size());
      |            ^~~
bubblesort2.cpp:20:22: 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 < A.size(); i++)
      |                    ~~^~~~~~~~~~
bubblesort2.cpp:21:9: error: 'curr' was not declared in this scope
   21 |         curr[i] = A[i];
      |         ^~~~
bubblesort2.cpp:22:23: error: 'curr' was not declared in this scope
   22 |     int cnt = get_cnt(curr);
      |                       ^~~~
bubblesort2.cpp:22:27: error: 'get_cnt' cannot be used as a function
   22 |     int cnt = get_cnt(curr);
      |                           ^
bubblesort2.cpp:26:25: error: 'get_cnt' cannot be used as a function
   26 |   answer[j]=get_cnt(curr);
      |                         ^
bubblesort2.cpp:22:9: warning: unused variable 'cnt' [-Wunused-variable]
   22 |     int cnt = get_cnt(curr);
      |         ^~~