제출 #826813

#제출 시각아이디문제언어결과실행 시간메모리
826813vjudge1Arranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define en '\n' #define all(v) v.begin(),v.end() const int N = 3e5 + 10; int a[N],b[N],n; ll calc(vector <int> g) { for(int i = 1;i <= 2 * n;i++)b[i] = a[i]; ll ans = 0; int last = 0; for(auto to : g) { for(int i = last + 1;i <= 2 * n;i++) { if(b[i] == -to) { for(int j = i - 1;j >= last + 1;j--) { ans++; swap(b[j],b[j + 1]); } break; } } last++; for(int i = last + 1;i <= 2 * n;i++) { if(b[i] == to) { for(int j = i - 1;j >= last + 1;j--) { ans++; swap(b[j],b[j + 1]); } break; } } last++; } return ans; } ll count_swaps(vector<int> S) { n = S.size(); vector <int> q; for(int i = 0;i < n;i++) { a[i + 1] = S[i]; if(S[i] > 0)q.pb(S[i]); } n /= 2; sort(all(q)); ll ans = calc(q); while(next_permutation(all(q))) { ans = min(ans,calc(q)); cnt++; } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:50:3: error: 'cnt' was not declared in this scope; did you mean 'int'?
   50 |   cnt++;
      |   ^~~
      |   int