Submission #168975

#TimeUsernameProblemLanguageResultExecution timeMemory
168975pulpy_orangeArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll count_swaps(vector<ll>S){
     int n=S.size();
     int ans=0;
     
     ll vis[n];
     memset(vis, 0, sizeof(vis));

     for(ll i=0;i<n;i++){
          if(vis[i])continue;
          ll curr=S[i];
          vis[i]=1;
          if(curr<0){
               for(ll j=i+1;j<n;j++){
                    if(!vis[j] and S[j]>0 and curr==-1*S[j]){
                         vis[j]=1;
                         ans+=(j-1-i);
                         break;
                    }
               }
          }
          else{
               for(ll j=i+1;j<n;j++){
                    if(!vis[j] and S[j]<0 and curr==-1*S[j]){
                         vis[j]=1;
                         ans+=(j-i);
                         break;
                    }
               }
          }
     }
     return ans;
}

Compilation message (stderr)

/tmp/ccjfnYcy.o: In function `main':
grader.cpp:(.text.startup+0x282): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status