QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#701870 | #8770. Comparator | ucup-team5062 | Compile Error | / | / | C++17 | 2.9kb | 2024-11-02 14:50:53 | 2024-11-02 14:50:55 |
Judging History
answer
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int parse(const string& s) {
const int L = s.size();
int pos = 0;
auto e1 = [&](auto& e1, auto& e2, auto& e3, auto& e4, auto& e5) -> int {
int res = e2(e1, e2, e3, e4, e5);
while (pos != L && s[pos] == '^') {
pos++;
res ^= e2(e1, e2, e3, e4, e5);
}
return res;
};
auto e2 = [&](auto& e1, auto& e2, auto& e3, auto& e4, auto& e5) -> int {
int res = e3(e1, e2, e3, e4, e5);
while (pos != L && s[pos] == '|') {
pos++;
res |= e3(e1, e2, e3, e4, e5);
}
return res;
};
auto e3 = [&](auto& e1, auto& e2, auto& e3, auto& e4, auto& e5) -> int {
int res = e4(e1, e2, e3, e4, e5);
while (pos != L && s[pos] == '&') {
pos++;
res &= e4(e1, e2, e3, e4, e5);
}
return res;
};
auto e4 = [&](auto& e1, auto& e2, auto& e3, auto& e4, auto& e5) -> int {
int res = e5(e1, e2, e3, e4, e5);
while (pos != L && s[pos] == '=') {
pos++;
res ^= e5(e1, e2, e3, e4, e5) ^ 1;
}
return res;
};
auto e5 = [&](auto& e1, auto& e2, auto& e3, auto& e4, auto& e5) -> int {
if (s[pos] == '0') {
pos++;
return 0;
}
if (s[pos] == '1') {
pos++;
return 1;
}
if (s[pos] == '!') {
pos++;
return 1 - e5(e1, e2, e3, e4, e5);
}
pos++; // '('
int res = e1(e1, e2, e3, e4, e5);
pos++; // ')'
return res;
};
return e1(e1, e2, e3, e4, e5);
}
int main() {
// step #1. input & make array
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, K;
cin >> N >> K;
vector<bitset<1024> > G(1 << K), H(1 << K);
vector<vector<array<bool, 4> > > vis(K, vector<array<bool, 4> >(K, {false, false, false, false}));
for (int i = 0; i < N; i++) {
int a, b, c; string s;
cin >> a >> b >> s >> c;
a--; b--;
for (int x = 0; x < 2; x++) {
for (int y = 0; y < 2; y++) {
string t = s;
replace(t.begin(), t.end(), 'x', char(x + '0'));
replace(t.begin(), t.end(), 'y', char(y + '0'));
int res = parse(t);
if (res == 1) {
if (!vis[a][b][x * 2 + y]) {
vis[a][b][x * 2 + y] = true;
for (int j = 0; j < (1 << K); j++) {
if (((j >> a) & 1) == x) {
for (int k = 0; k < (1 << K); k++) {
if (((k >> b) & 1) == y && H[j][k] == 0) {
G[j][k] = c;
H[j][k] = 1;
}
}
}
}
}
}
}
}
}
int R;
cin >> R;
for (int i = 0; i < (1 << K); i++) {
for (int j = 0; j < (1 << K); j++) {
if (H[i][j] == 0) {
G[i][j] = R;
}
}
}
// step #2. calculate answer
int ans1 = 0, ans2 = 0, ans3 = 0;
for (int i = 0; i < (1 << K); i++) {
ans1 += int(G[i][i] == 1);
for (int j = 0; j < (1 << K); j++) {
ans2 += int(G[i][j] == 1 && G[j][i] == 1);
if (G[i][j] == 1) {
ans3 += (~G[i] & G[j]).count();
}
}
}
// step #3. output
cout << ans1 << ' ' << ans2 << ' ' << ans3 << endl;
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:71:104: error: no matching function for call to ‘std::vector<std::array<bool, 4> >::vector(int&, <brace-enclosed initializer list>)’ 71 | vector<vector<array<bool, 4> > > vis(K, vector<array<bool, 4> >(K, {false, false, false, false})); | ^ In file included from /usr/include/c++/13/vector:66, from answer.code:3: /usr/include/c++/13/bits/stl_vector.h:704:9: note: candidate: ‘template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::array<bool, 4>; _Alloc = std::allocator<std::array<bool, 4> >]’ 704 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/13/bits/stl_vector.h:704:9: note: template argument deduction/substitution failed: In file included from /usr/include/c++/13/bits/stl_algobase.h:65, from /usr/include/c++/13/bitset:49, from answer.code:1: /usr/include/c++/13/bits/stl_iterator_base_types.h: In substitution of ‘template<class _InIter> using std::_RequireInputIter = std::__enable_if_t<std::is_convertible<typename std::iterator_traits< <template-parameter-1-1> >::iterator_category, std::input_iterator_tag>::value> [with _InIter = int]’: /usr/include/c++/13/bits/stl_vector.h:702:9: required from here /usr/include/c++/13/bits/stl_iterator_base_types.h:250:11: error: no type named ‘iterator_category’ in ‘struct std::iterator_traits<int>’ 250 | using _RequireInputIter = | ^~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_vector.h:675:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::array<bool, 4>; _Alloc = std::allocator<std::array<bool, 4> >; allocator_type = std::allocator<std::array<bool, 4> >]’ 675 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/13/bits/stl_vector.h:675:43: note: no known conversion for argument 1 from ‘int’ to ‘std::initializer_list<std::array<bool, 4> >’ 675 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/13/bits/stl_vector.h:656:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::array<bool, 4>; _Alloc = std::allocator<std::array<bool, 4> >; std::__type_identity_t<_Alloc> = std::allocator<std::array<bool, 4> >]’ 656 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/13/bits/stl_vector.h:656:23: note: no known conversion for argument 1 from ‘int’ to ‘std::vector<std::array<bool, 4> >&&’ 656 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ~~~~~~~~~^~~~ /usr/include/c++/13/bits/stl_vector.h:637:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::array<bool, 4>; _Alloc = std::allocator<std::array<bool, 4> >; allocator_type = std::allocator<std::array<bool, 4> >; std::false_type = std::integral_constant<bool, false>]’ 637 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/13/bits/stl_vector.h:637:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/13/bits/stl_vector.h:632:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::array<bool, 4>; _Alloc = std::allocator<std::array<bool, 4> >; allocator_type = std::allocator<std::array<bool, 4> >; std::true_type = std::integral_constant<bool, true>]’ 632 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/13/bits/stl_vector.h:632:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/13/bits/stl_vector.h:621:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::array<bool, 4>; _Alloc = std::allocator<std::array<bool, 4> >; std::__type_identity_t<_Alloc> = std::allocator<std::array<bool, 4> >]’ 621 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/13/bits/stl_vector.h:621:28: note: no known conversion for argument 1 from ‘int’ to ‘const std::vector<std::array<bool, 4> >&’ 621 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/13/bits/stl_vector.h:617:7: note: candidate: ‘std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::array<bool, 4>; _Alloc = std::allocator...