제출 #298251

#제출 시각아이디문제언어결과실행 시간메모리
298251RayaabualjamalArranging Shoes (IOI19_shoes)C++14
65 / 100
1081 ms2048 KiB
#include "shoes.h" #include <iostream> #include <vector> #include <cstdio> #define rep(i,a,b) for(int i = a; i<b; i++) #define per(i,a,b) for(int i = a; i>b; i--) #define pb push_back using namespace std; long long count_swaps(vector<int> s) { int n = s.size()/2; bool f = 1; rep(i,0,n)if(s[i]>0)f = 0; rep(i,n,n+n)if(s[i]<0)f = 0; rep(i,0,n)if(s[i]!=(-s[i+n]))f = 0; if(f){ long long ans = 0; rep(i,0,n){ ans+= i; } return ans; } n*=2; long long ans = 0; rep(i,0,n){ if(s[i]<0){ int pos; rep(j,i+1,n){ if((-s[i]) == s[j]){ pos = j; break; } } per(j,pos, i+1){ swap(s[j], s[j-1]); ans++; } }else{ int pos; rep(j,i+1,n){ if((-s[i]) == s[j]){ pos = j; break; } } per(j,pos, i){ swap(s[j], s[j-1]); ans++; } } //cout << s[i] << endl; i++; } //cout << "ans: " << ans << endl; return ans; }

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:38:8: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |    int pos;
      |        ^~~
shoes.cpp:26:8: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |    int pos;
      |        ^~~
#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...