Submission #301910

#TimeUsernameProblemLanguageResultExecution timeMemory
301910NicolaAbusaad2014Arranging Shoes (IOI19_shoes)C++14
50 / 100
1074 ms3704 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { long n=s.size(); long long arr[n]={},x,z,ans=0; bool ok[n]={}; for(long i=0;i<n;i++){ if(!ok[i]){ for(long j=i+1;j<n;j++){ if(s[j]==(-s[i])&&(!ok[j])){ ok[j]=true; x=j; break; } arr[j]++; } ans+=(x+arr[x])-(i+arr[i])-1; if(s[i]>0){ ans++; } } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:27: warning: unused variable 'z' [-Wunused-variable]
    7 |     long long arr[n]={},x,z,ans=0;
      |                           ^
shoes.cpp:19:12: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |     ans+=(x+arr[x])-(i+arr[i])-1;
      |          ~~^~~~~~~~
#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...