Submission #915972

#TimeUsernameProblemLanguageResultExecution timeMemory
915972AiperiiiArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include "shoes.h" #define int long long long long count_swaps(std::vector<int> s) { int x=abs(s[0]); set <int> v; for(int i=0;i<s.size();i++){ if(s[i]==-x && i%2==1)v.insert(i); } int ans=0; for(int i=0;i<s.size();i++){ if(i%2==0 && s[i]==x){ auto it=v.upper_bound(i); ans+=(*it-i); v.erase(it); } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<long long int>)':
shoes.cpp:4:11: error: 'abs' was not declared in this scope
    4 |     int x=abs(s[0]);
      |           ^~~
shoes.cpp:5:5: error: 'set' was not declared in this scope
    5 |     set <int> v;
      |     ^~~
shoes.cpp:2:13: error: expected primary-expression before 'long'
    2 | #define int long long
      |             ^~~~
shoes.cpp:5:10: note: in expansion of macro 'int'
    5 |     set <int> v;
      |          ^~~
shoes.cpp:6:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
shoes.cpp:7:30: error: 'v' was not declared in this scope
    7 |        if(s[i]==-x && i%2==1)v.insert(i);
      |                              ^
shoes.cpp:10:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
shoes.cpp:12:19: error: 'v' was not declared in this scope
   12 |           auto it=v.upper_bound(i);
      |                   ^