제출 #1215777

#제출 시각아이디문제언어결과실행 시간메모리
1215777SzilArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { int n = s.size()/2; vector<int> v = s; for (int &i : v) cin >> i; vector<int> goal; map<int, int> cnt; for (int i = 0; i < 2*n; i++) { int x = abs(v[i]); if (cnt[x] % 2 == 0) { goal.emplace_back(-x); goal.emplace_back(x); } cnt[x]++; } vector<bool> done(2*n); vector<int> arr; for (int i = 0; i < 2*n; i++) { int j = 0; for (; j < 2*n; j++) { if (!done[j] && goal[j] == v[i]) { break; } } done[j] = 1; arr.emplace_back(j); } int curr = 0; for (int i = 0; i < 2*n; i++) { for (int j = 0; j < i; j++) { if (arr[j] > arr[i]) curr++; } } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:42:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |     return ans;
      |            ^~~
      |            abs