Submission #543072

#TimeUsernameProblemLanguageResultExecution timeMemory
543072Anas_AbuAmarArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
//#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { int ans = 0; deque<int>d; for (auto &i:s){ d.push_back(i); } while(!d.empty()) int cur = d.front(); auto next = find (d.begin() , d.end() ,cur*-1); ans += (next-d.begin()); if (cur > 0 ){ ans++; } d.pop_front(); d.erase(next); } return ans; } int main() { int n; assert(1 == scanf("%d", &n)); vector<int> S(2 * n); for (int i = 0; i < 2 * n; i++) assert(1 == scanf("%d", &S[i])); fclose(stdin); long long result = count_swaps(S); printf("%lld\n", result); fclose(stdout); return 0; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:4: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   10 |    while(!d.empty())
      |    ^~~~~
shoes.cpp:12:7: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   12 |       auto next = find (d.begin() , d.end() ,cur*-1);
      |       ^~~~
shoes.cpp:11:11: warning: unused variable 'cur' [-Wunused-variable]
   11 |       int cur = d.front();
      |           ^~~
shoes.cpp:12:46: error: 'cur' was not declared in this scope
   12 |       auto next = find (d.begin() , d.end() ,cur*-1);
      |                                              ^~~
shoes.cpp:19:4: warning: no return statement in function returning non-void [-Wreturn-type]
   19 |    }
      |    ^
shoes.cpp: At global scope:
shoes.cpp:20:4: error: expected unqualified-id before 'return'
   20 |    return ans;
      |    ^~~~~~
shoes.cpp:21:1: error: expected declaration before '}' token
   21 | }
      | ^