Submission #631757

#TimeUsernameProblemLanguageResultExecution timeMemory
631757StavabArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
using namespace std;

long long count_swaps(vector<int> S)
{
    long long sum = 0;
    int temp;
    
    for(int i = 0; i < S.size() - 1; i += 2)
    {
        temp = 0;
        for(int j = i + 1; j < S.size(); j++)
        {
            if(temp)
                swap(temp, S[j]);
            else
                temp = S[j];
                
            if(temp == -S[i])
            {
                if(temp < 0)
                    sum += j - i;
                else
                    sum += j - i - 1;
                    
                break;
            }
        }
    }
    
    return sum;
}

Compilation message (stderr)

shoes.cpp:3:23: error: 'vector' was not declared in this scope
    3 | long long count_swaps(vector<int> S)
      |                       ^~~~~~
shoes.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | using namespace std;
shoes.cpp:3:30: error: expected primary-expression before 'int'
    3 | long long count_swaps(vector<int> S)
      |                              ^~~