Submission #952685

#TimeUsernameProblemLanguageResultExecution timeMemory
952685batsukh2006Arranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include<iostream> #include<stdio.h> #include<math.h> #include<map> #include<string> #include<algorithm> #include<vector> #include<string.h> #include<utility> #include<set> #include<cmath> #include<queue> #include<deque> #include<functional> #include<stack> #include<limits.h> #include<iomanip> #include<unordered_map> #include "shoes.h" using namespace std; void count_swaps(vector<int> s){ map<int,int> m; vector<int> res(s.size()); for(int i=0,j=0; i<s.size(); i++){ if(m[s[i]]==0){ if(s[i]<0){ res[j]=s[i]; res[j+1]=-s[i]; }else{ res[j]=-s[i]; res[j+1]=s[i]; } j+=2; m[-s[i]]++; }else{ m[s[i]]--; } } int i=0,ans=0; while(i<s.size()){ int j=i; while(res[i]!=s[j]) j++; while(i<j){ int t=s[j]; s[j]=s[j-1]; s[j-1]=t; j--; ans++; } i++; } return ans; } // signed main(){ // // freopen("hps.in", "r", stdin); // // freopen("hps.out", "w", stdout); // ios::sync_with_stdio(0); // cin.tie(0); // cout.tie(0); // int t=1; // // cin>>t; // while(t--){ // cout<<endl; // } // return 0; // }

Compilation message (stderr)

shoes.cpp:24:6: error: ambiguating new declaration of 'void count_swaps(std::vector<int>)'
   24 | void count_swaps(vector<int> s){
      |      ^~~~~~~~~~~
In file included from shoes.cpp:20:
shoes.h:7:11: note: old declaration 'long long int count_swaps(std::vector<int>)'
    7 | long long count_swaps(std::vector<int> S);
      |           ^~~~~~~~~~~
shoes.cpp: In function 'void count_swaps(std::vector<int>)':
shoes.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0,j=0; i<s.size(); i++){
      |                      ~^~~~~~~~~
shoes.cpp:43:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     while(i<s.size()){
      |           ~^~~~~~~~~
shoes.cpp:55:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   55 |     return ans;
      |            ^~~