Submission #1272955

#TimeUsernameProblemLanguageResultExecution timeMemory
1272955arkanefuryArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include "shoes.h" using namespace std; const int N = 2e5+5; int a[N], b[N]; long long count_swaps(vector <int> v){ int n = v.size(), k; long long ans = 0; for(int i = 0; i < n; i += 2){ if(v[i] < 0){ for(int j = i+1; j < n; i ++){ if(v[j] > 0 && v[j] == abs(v[i])){ k = j;break; } } for(int j = k; j > i+1; j --){ swap(a[j], a[j-1]); ans ++; } } else{ for(int j = i+1; j < n; i ++){ if(v[j] < 0 && abs(v[j]) == v[i]){ k = j;break; } } for(int j = k; j > i; j --){ swap(a[j], a[j-1]); ans ++; } } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:11:48: error: 'abs' was not declared in this scope; did you mean 'ans'?
   11 |                         if(v[j] > 0 && v[j] == abs(v[i])){
      |                                                ^~~
      |                                                ans
shoes.cpp:22:40: error: 'abs' was not declared in this scope; did you mean 'ans'?
   22 |                         if(v[j] < 0 && abs(v[j]) == v[i]){
      |                                        ^~~
      |                                        ans