QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#117572 | #6628. Flip it and Stick it | bashkort# | Compile Error | / | / | C++20 | 3.3kb | 2023-07-01 18:14:43 | 2024-05-31 18:46:01 |
Judging History
你现在查看的是最新测评结果
- [2024-05-31 18:46:01]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-01 18:14:43]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s, t;
cin >> s >> t;
const int n = size(s), m = size(t);
if (t[0] == '1') {
char x = '0' ^ '1';
for (char &c : s) {
c ^= x;
}
for (char &c : t) {
c ^= x;
}
}
if (m == 1) {
cout << (s.find(t) == string::npos ? 0 : -1) << '\n';
} else if (m == 2) {
if (t[0] != t[1]) {
int till = n - (find(s.rbegin(), s.rend(), '1') - s.rbegin());
int ans = 0;
for (int i = 0, j = 0; i < till; i = j) {
while (j < n && s[i] == s[j]) {
j += 1;
}
ans += s[i] == '0';
}
cout << ans << '\n';
} else {
int cnt = count(s.begin(), s.end(), '1');
if (cnt * 2 + 1 < n) {
cout << "-1\n";
} else {
int ans = 0;
for (int i = 0, j = 0; i < n; i = j) {
while (j < n && s[i] == s[j]) {
j += 1;
}
if (s[i] == '0') {
ans += j - i - 1;
}
}
cout << ans << '\n';
}
}
} else {
if (s.find(t) == string::npos) {
cout << "0\n";
return 0;
}
if (t == "001") {
char x = '0' ^ '1';
for (char &c : s) {
c ^= x;
}
for (char &c : t) {
c ^= x;
}
reverse(s.begin(), s.end());
reverse(t.begin(), t.end());
}
if (t == "011") {
int ans = 0;
vector<bool> a(n);
for (int i = 0; i < n; ++i) {
if (s[i] == '0' || (i > 0 && s[i - 1] == '0')) {
a[i] = true;
}
}
int la = n - (find(a.rbegin(), a.rend(), false) - a.rbegin());
for (int i = 0; i < la - 1; ++i) {
if (a[i] != a[i + 1] && a[i]) {
ans += 1;
}
}
cout << ans << '\n';
} else if (t == "000") {
int cnt = count(s.begin(), s.end(), '1') - s.begin();
if (cnt * 3 + 2 < n) {
cout << "-1\n";
} else {
int ans = 0;
for (int i = 0, j = 0; i < n; i = j) {
while (j < n && s[i] == s[j]) {
j += 1;
}
if (s[i] == '0') {
ans += (j - i - 1) / 2;
}
}
cout << ans << '\n';
}
} else if (t == "010") {
int ans = 0;
for (int i = 1; i < n - 1; ++i) {
if (s[i] == '1' && s[i - 1] == s[i + 1] && s[i - 1] == '0') {
ans += 1;
}
}
cout << (ans + 1) / 2 << '\n';
} else {
assert(false);
}
}
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:87:54: error: no match for ‘operator-’ (operand types are ‘std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type’ {aka ‘long int’} and ‘std::__cxx11::basic_string<char>::iterator’) 87 | int cnt = count(s.begin(), s.end(), '1') - s.begin(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~ | | | | | std::__cxx11::basic_string<char>::iterator | std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type {aka long int} In file included from /usr/include/c++/13/bits/stl_algobase.h:67, from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_iterator.h:625:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_IteratorL>&, const reverse_iterator<_IteratorR>&)’ 625 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:625:5: note: template argument deduction/substitution failed: answer.code:87:64: note: mismatched types ‘const std::reverse_iterator<_IteratorL>’ and ‘std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type’ {aka ‘long int’} 87 | int cnt = count(s.begin(), s.end(), '1') - s.begin(); | ^ /usr/include/c++/13/bits/stl_iterator.h:1800:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’ 1800 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1800:5: note: template argument deduction/substitution failed: answer.code:87:64: note: mismatched types ‘const std::move_iterator<_IteratorL>’ and ‘std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type’ {aka ‘long int’} 87 | int cnt = count(s.begin(), s.end(), '1') - s.begin(); | ^ In file included from /usr/include/c++/13/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127: /usr/include/c++/13/complex:365:5: note: candidate: ‘template<class _Tp> constexpr std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)’ 365 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/13/complex:365:5: note: template argument deduction/substitution failed: answer.code:87:64: note: mismatched types ‘const std::complex<_Tp>’ and ‘std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type’ {aka ‘long int’} 87 | int cnt = count(s.begin(), s.end(), '1') - s.begin(); | ^ /usr/include/c++/13/complex:374:5: note: candidate: ‘template<class _Tp> constexpr std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)’ 374 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/13/complex:374:5: note: template argument deduction/substitution failed: answer.code:87:64: note: mismatched types ‘const std::complex<_Tp>’ and ‘std::__iterator_traits<__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, void>::difference_type’ {aka ‘long int’} 87 | int cnt = count(s.begin(), s.end(), '1') - s.begin(); | ^ /usr/include/c++/13/complex:383:5: note: candidate: ‘template<class _Tp> constexpr std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)’ 383 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/13/complex:383:5: note: template argument deduction/substitution failed: answer.code:87:64: note: ‘std::__cxx11::basic_string<char>::iterator’ is not derived from ‘const std::complex<_Tp>’ 87 | int cnt = count(s.begin(), s.end(), '1') - s.begin(); | ^ /usr/include/c++/13/complex:460:5: note: candidate: ‘template<class _Tp> constexpr std::complex<_Tp> std::operator-(const complex<_Tp>&)’ 460 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/13/complex:460:5: note: t...