Submission #912464

#TimeUsernameProblemLanguageResultExecution timeMemory
912464agusssArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "vector" #include "stdio.h" #include "iostream" using namespace std; long long count_swaps(std::vector<int> s) { vector<bool> used(s.size(), false); long long cnt = 0; // cout << "size:" << s.size() << "\n"; for (int i = 0; i < s.size(); i++) { int j; if (used[i]) { continue; } // cout << "to pair" << i << "\n"; for (j = i + 1; j < s.size(); j++) { if (s[j] == -s[i] and !used[j]) { used[j] = true; break; } } if (j < s.size()) { // cout << i << ", " << j << "\n"; long long distance = j - i - (s[i] < 0 ? 1 : 0); cnt += distance; } } return cnt; } int main() { int n; scanf("%d\n", &n); vector<int> A(n << 1); for (int i = 0; i < n << 1; i++) { scanf("%d", &A[i]); } printf("%lld\n", count_swaps(A)); return 0; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:11:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |   for (int i = 0; i < s.size(); i++) {
      |                   ~~^~~~~~~~~~
shoes.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (j = i + 1; j < s.size(); j++) {
      |                     ~~^~~~~~~~~~
shoes.cpp:23:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     if (j < s.size()) {
      |         ~~^~~~~~~~~~
shoes.cpp: In function 'int main()':
shoes.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |   scanf("%d\n", &n);
      |   ~~~~~^~~~~~~~~~~~
shoes.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%d", &A[i]);
      |     ~~~~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccYIzDXt.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccbyXPRu.o:shoes.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status