Submission #1311412

#TimeUsernameProblemLanguageResultExecution timeMemory
1311412nikoloz-chArranging Shoes (IOI19_shoes)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "shoes.h"
using namespace std;

long long count_swaps(int []S){
    int ans = 0;
    map<int,int> mp;
    for(int i = 0; i < S.size(); i++){
        mp[S[i]] = i;
    }
    for(int i = 0; i < S.size(); i++){
        if(S[i] < 0) continue;
        if(st.find(S[i]) != st.end()){
            ans += abs(mp[S[i]]-mp[-S[i]]);
            st.insert(-S[i]); st.insert(S[i]);
        }
    }
    return ans;
}

Compilation message (stderr)

shoes.cpp:5:29: error: expected ',' or '...' before 'S'
    5 | long long count_swaps(int []S){
      |                             ^
shoes.cpp: In function 'long long int count_swaps(int*)':
shoes.cpp:8:24: error: 'S' was not declared in this scope
    8 |     for(int i = 0; i < S.size(); i++){
      |                        ^
shoes.cpp:11:24: error: 'S' was not declared in this scope
   11 |     for(int i = 0; i < S.size(); i++){
      |                        ^
shoes.cpp:13:12: error: 'st' was not declared in this scope; did you mean 'std'?
   13 |         if(st.find(S[i]) != st.end()){
      |            ^~
      |            std