Submission #316792

#TimeUsernameProblemLanguageResultExecution timeMemory
316792Tahmid690Arranging Shoes (IOI19_shoes)C++14
25 / 100
32 ms1924 KiB
#include<bits/stdc++.h> #include "shoes.h" using namespace std; long long count_swaps(vector<int> ara){ int flag=0; for(int i=1;i<ara.size();i++) if(abs(ara[i])!=abs(ara[i-1])) flag=1; if(flag==0){ long long ans=0; long long x=0; for(int i=0;i<ara.size();i++){ if(i%2==1 && ara[i]<0){ for(int j=0;j<ara.size();j++){ if(j%2==0 && ara[j]>0){ swap(ara[i],ara[j]); ans+=(abs(j-i)); } } } } return ans; } long long n; n=ara.size(); n/=2; if(n==1){ if(ara[0]<0) return 0; else return 1; } return (n*(n-1))/2; } /*int main(){ int n; cin >> n; vector<int> vct; while(n--){ int x; cin >> x; vct.push_back(x); } cout << count_swaps(vct) << endl; }*/

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i=1;i<ara.size();i++) if(abs(ara[i])!=abs(ara[i-1])) flag=1;
      |                 ~^~~~~~~~~~~
shoes.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for(int i=0;i<ara.size();i++){
      |                     ~^~~~~~~~~~~
shoes.cpp:15:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |                 for(int j=0;j<ara.size();j++){
      |                             ~^~~~~~~~~~~
shoes.cpp:11:19: warning: unused variable 'x' [-Wunused-variable]
   11 |         long long x=0;
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...