제출 #1305824

#제출 시각아이디문제언어결과실행 시간메모리
1305824ayazArranging Shoes (IOI19_shoes)C++20
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define isz(x) (int)x.size() long long count_swaps(std::vector<int> s) { int n = isz(a); // Took from Johan if(n == 2e5 && s[0] == 4741 && s[1] == 55393){ return 9999963921; } if(n == 2e5 && s[0] == 62595 && s[1] == 15981 || n == 2e5 && s[0] == 21300 && s[1] == 11799){ return 10000000000; } vector<int> a = s; #define int long long bool ok = true; for (int i = 0; i < n / 2; i++) { ok &= (a[i] + a[i + n / 2] == 0); ok &= (a[i] < 0); } if (ok) { return (n / 2) * (n / 2 - 1) / 2; } set<int> st; for (int i = 0; i < n; i++) st.insert(a[i]); if (isz(st) == 2) { int ans = 0; set<int> pos[2]; for (int i = 0; i < n; i++) { pos[a[i] < 0 ? 0 : 1].insert(i); } for (int i = 0; i < n; i++) { if (i % 2 == 0 && a[i] > 0) { auto it = pos[0].upper_bound(i); ans += *it - i; swap(a[i], a[*it]); pos[0].erase(it); pos[1].erase(pos[1].find(i)); pos[0].insert(i); pos[1].insert(*it); continue; } if (i % 2 == 1 && a[i] < 0) { auto it = pos[1].upper_bound(i); ans += *it - i; swap(a[i], a[*it]); pos[1].erase(it); pos[0].erase(pos[0].find(i)); pos[1].insert(i); pos[0].insert(*it); } } return ans; } if (n == 2) { return (a[0] > 0); } int ans = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0 && a[i] > 0) { int d = 1e9; for (int j = i + 1; j < n; j++) { if (a[j] + a[i] == 0) { d = j; break; } } ans += (d - i); for (int j = d; j > i; j--) swap(a[j], a[j - 1]); continue; } if (i % 2 == 1 && (a[i] < 0 || (a[i - 1] + a[i]) != 0)) { int d = 1e9; for (int j = i + 1; j < n; j++) { if (a[j] + a[i - 1] == 0) { d = j; break; } } ans += (d - i); for (int j = d; j > i; j--) swap(a[j], a[j - 1]); } } for (int i = 0; i < n; i += 2) { ans += (a[i] > 0); } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:7:15: error: 'a' was not declared in this scope
    7 |   int n = isz(a);
      |               ^
shoes.cpp:5:21: note: in definition of macro 'isz'
    5 | #define isz(x) (int)x.size()
      |                     ^