제출 #301902

#제출 시각아이디문제언어결과실행 시간메모리
301902NicolaAbusaad2014Arranging Shoes (IOI19_shoes)C++14
10 / 100
1 ms384 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]){ ok[i]=false; } else{ for(long j=i+1;j<n;j++){ if(s[j]==-s[i]){ ok[j]=true; x=j; break; } arr[j]++; } ans+=(x+arr[x])-(i+arr[i])-1; if(s[i]>0){ ans++; } } } return ans; }

컴파일 시 표준 에러 (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:22:12: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |     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...