제출 #1215811

#제출 시각아이디문제언어결과실행 시간메모리
1215811szz0liArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> s) { int ans=INT_MAX/2; int n=s.size()/2; vector<int> perm; for(int i=0;i<n*2;i++){ if(s[i]<0)perm.push_back(abs(s[i])); } sort(perm.begin(), perm.end()); do{ int cnt=0; vector<int> helyes(2*n), copi=s; for(int i=0;i<n;i++){ helyes[2*i]=-1*perm[i]; helyes[2*i+1]=perm[i]; } for(int i=0;i<2*n;i++){ for(int j=i;j<2*n;j++){ if(copi[j]==helyes[i]){ while(j!=i){ swap(copi[j], copi[j-1]); j--; cnt++; } break; } } ans=min(ans, cnt); } while(next_permutation(perm.begin(), perm.end())); return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:36:2: error: expected 'while' at end of input
   36 | }
      |  ^
shoes.cpp:36:2: error: expected '(' at end of input
   36 | }
      |  ^
      |  (
shoes.cpp:36:2: error: expected primary-expression at end of input
shoes.cpp:36:2: error: expected ')' at end of input
   36 | }
      |  ^
      |  )
shoes.cpp:36:2: error: expected ';' at end of input
   36 | }
      |  ^
      |  ;
shoes.cpp:36:2: error: expected '}' at end of input
shoes.cpp:5:38: note: to match this '{'
    5 | long long count_swaps(vector<int> s) {
      |                                      ^