Submission #197392

#TimeUsernameProblemLanguageResultExecution timeMemory
197392Ahmed_SelimArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <cstring> #include <vector> #include <set> #include <algorithm> #define MOD 1000000007 using namespace std; long long int cvp, n; vector<int> konum[2][200010]; long long int count_swaps(int[] arr){ for (n = 0; arr[n] ; ++n){ if(arr[n]<0)konum[1][arr[n]].push_back(n); else konum[0][arr[n]].push_back(n); } for (int i = 0; i < n; i+=2){ if(arr[i]<0){ int j=0; while(konum[0][arr[i]][j]<0)j++; int index=konum[0][arr[i]][j]; while(index!=i+1){ swap(arr[index], arr[index-1]); cvp++; } konum[0][arr[i]][j]=-1; }else{ int j=0; while(konum[0][arr[i]][j]<0)j++; int index=konum[0][arr[i]][j]; while(index!=i+1){ swap(arr[index], arr[index-1]); cvp++; } konum[0][arr[i]][j]=-1; cvp++; } } return cvp; }

Compilation message (stderr)

shoes.cpp:12:33: error: expected ',' or '...' before 'arr'
 long long int count_swaps(int[] arr){
                                 ^~~
shoes.cpp: In function 'long long int count_swaps(int*)':
shoes.cpp:13:14: error: 'arr' was not declared in this scope
  for (n = 0; arr[n] ; ++n){
              ^~~
shoes.cpp:18:6: error: 'arr' was not declared in this scope
   if(arr[i]<0){
      ^~~