Submission #965368

# Submission time Handle Problem Language Result Execution time Memory
965368 2024-04-18T11:51:30 Z akacool445k Arranging Shoes (IOI19_shoes) C++14
Compilation error
0 ms 0 KB
#include "shoes.h"

long long count_swaps(std::vector<int> s) {
	long long n = s.size();
	long long ans = 0;
	vector<int> c(n, 1);
	for (int i = 0; i < n; i++) {
		if (c[i] == 0) continue;
		int ss = 0;
		for (int j = i + 1; j < n; j++) {
			if (s[i] + s[j] == 0) {
				ans += ss;
				c[j] = 0;
				break;
			} else {
				ss += c[j];
			}
		}
		if (s[i] > 0) ans++;
	}
	return ans;
}

Compilation message

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:2: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    6 |  vector<int> c(n, 1);
      |  ^~~~~~
      |  std::vector
In file included from /usr/include/c++/10/vector:67,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
shoes.cpp:6:9: error: expected primary-expression before 'int'
    6 |  vector<int> c(n, 1);
      |         ^~~
shoes.cpp:8:7: error: 'c' was not declared in this scope
    8 |   if (c[i] == 0) continue;
      |       ^
shoes.cpp:13:5: error: 'c' was not declared in this scope
   13 |     c[j] = 0;
      |     ^
shoes.cpp:16:11: error: 'c' was not declared in this scope
   16 |     ss += c[j];
      |           ^