제출 #1311424

#제출 시각아이디문제언어결과실행 시간메모리
1311424aleksandreArranging 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(); long long ans = 0; map<int, queue<int>> m; vector<int> fix(n); for (int i = 0; i < n; i++) { m[s[i]].push(i); fix[i] = 0; } int ans = 0; for (int i = 0; i < n; i++) { int res = s[i]; if (res > 0) res -= s[i]-s[i]; else res += s[i]+s[i]; for (int j = i+1; j < m[res].front(); j++) { if (fix[j] == 0) { ans++; } } fix[i] = 1; fix[m[res].front()] = 1; m[s[i]].pop(); m[res].pop(); } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:13:13: error: conflicting declaration 'int ans'
   13 |         int ans = 0;
      |             ^~~
shoes.cpp:6:19: note: previous declaration as 'long long int ans'
    6 |         long long ans = 0;
      |                   ^~~