Submission #1165837

#TimeUsernameProblemLanguageResultExecution timeMemory
1165837SG2AlokArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
long long ans = 0; for(int i = 0; i < s.size(); i++){ if(s[i] < 0){ int pos = -1; for(int j = i + 1; j < s.size(); j++){ if(s[j] == -s[i]){ pos = j; break; } } while(pos > i + 1){ swap(s[pos], s[pos - 1]); pos--; ans++; } i++; } else if(s[i] > 0){ int pos = -1; for(int j = i + 1; j < s.size(); j++){ if(s[j] == -s[i]){ pos = j; break; } } while(pos > i){ swap(s[pos], s[pos - 1]); pos--; ans++; } } } return ans;

Compilation message (stderr)

shoes.cpp:2:9: error: expected unqualified-id before 'for'
    2 |         for(int i = 0; i < s.size(); i++){
      |         ^~~
shoes.cpp:2:28: error: 's' was not declared in this scope
    2 |         for(int i = 0; i < s.size(); i++){
      |                            ^
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:28: error: 's' was not declared in this scope
shoes.cpp:2:24: error: 'i' does not name a type
    2 |         for(int i = 0; i < s.size(); i++){
      |                        ^
shoes.cpp:2:38: error: 'i' does not name a type
    2 |         for(int i = 0; i < s.size(); i++){
      |                                      ^
shoes.cpp:36:9: error: expected unqualified-id before 'return'
   36 |         return ans;
      |         ^~~~~~