# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1004454 | Nailuj_217 | Furniture (JOI20_furniture) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define l long long
using namespace std;
const l LEN = 1005;
l n, m;
array<bitset<LEN>, LEN> grid;
array<bitset<LEN>, LEN> possible, visited, updatepossible;
bool dfs(l x, l y) {
if (visited[x][y]) return possible[x][y];
visited[x][y] = true;
if (grid[x][y]) return possible[x][y] = false;
if (x == n && y == m) return possible[x][y] = true;
if (x != n)
if (dfs(x+1, y)) possible[x][y] = true;
if (y != m)
if (dfs(x, y+1)) possible[x][y] = true;
return possible[x][y];
}
bool dfsback(l x, l y) {
if (!updatepossible[x][y]) return false;
if (grid[x][y]) return false;
if (x != n && updatepossible[x+1][y]) return true;
if (y != m && updatepossible[x][y+1]) return true;
updatepossible[x][y] = false;
bool isval = false;
if (x != 1 && dfsback(x-1, y)) isval = true;
if (y != 1 && dfsback(x, y-1)) isval = true;
return isval;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> grid[i][j];
dfs(1, 1);
l q, x, y;
bool left, top;
cin >> q;
while (q--) {
cin >> x >> y;
if (!possible[x][y]) {
grid[x][y] = true;
cout << 1 << "\n";
continue;
}
updatepossible = possible;
updatepossible[x][y] = false;
if (x != 1) dfsback(x-1, y);
if (y != 1) dfsback(x, y-1);
if (x != 1) dfsback(x-1, y);
// if (top || left) {
// if (x != 1 && top) top = dfsback(x-1, y);
// if (y != 1 && left) left = dfsback(x, y-1);
// }
if (updatepossible[1][1]) {
possible = updatepossible;
grid[x][y] = true;
cout << 1 << "\n";
} else {
cout << 0 << "\n";
}
}
return 0;
}
/*
6 8
0 0 0 0 0 0 0 0
0 1 0 0 0 0 1 0
0 1 0 0 1 1 1 0
0 1 0 0 1 0 1 0
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0
100
4 6
1 2
6 1
5 1
4 1
3 1
2 1
6 2
6 3
4 3
4 4
4 8
5 8
6 8
0 0 0 0 0 0 0 0
0 1 0 0 0 0 1 0
0 1 0 0 1 1 1 0
0 1 0 0 1 0 1 0
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0
100
6 6
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
100
2 2
1
3 2
1
4 2
1
5 2
1
5 1
1
4 1
1
3 1
1
2 1
1
1 4
1
2 4
1
2 5
1
1 5
1
4 4
1
3 3
0
4 5
1
5 4
1
5 5
0
*/
Compilation message (stderr)
furniture.cpp: In function 'int main()': furniture.cpp:46:17: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::bitset<1005>::reference') 46 | cin >> grid[i][j]; | ~~~ ^~ ~~~~~~~~~~ | | | | | std::bitset<1005>::reference | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:168:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 168 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/10/istream:168:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'bool&' to an rvalue of type 'bool' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:172:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 172 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/10/istream:172:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'short int&' to an rvalue of type 'short int' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:175:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 175 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/10/istream:175:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to an rvalue of type 'short unsigned int' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:179:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 179 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/10/istream:179:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:182:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 182 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/10/istream:182:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'unsigned int&' to an rvalue of type 'unsigned int' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:186:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 186 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/10/istream:186:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'long int&' to an rvalue of type 'long int' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:190:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 190 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/10/istream:190:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to an rvalue of type 'long unsigned int' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:195:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 195 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/10/istream:195:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/10/istream:199:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to an rvalue of type 'long long unsigned int' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:214:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 214 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/10/istream:214:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'float&' to an rvalue of type 'float' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:218:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 218 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/10/istream:218:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:222:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' (near match) 222 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/10/istream:222:7: note: conversion of argument 1 would be ill-formed: furniture.cpp:46:29: error: cannot bind non-const lvalue reference of type 'long double&' to an rvalue of type 'long double' 46 | cin >> grid[i][j]; | ~~~~~~~~~^ In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:66, from furniture.cpp:1: /usr/include/c++/10/bitset:854:2: note: after user-defined conversion: 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 1005]' 854 | operator bool() const _GLIBCXX_NOEXCEPT | ^~~~~~~~ furniture.cpp:46:17: note: candidate: 'operator>>(int, int)' (built-in) 46 | cin >> grid[i][j]; | ~~~~^~~~~~~~~~~~~ furniture.cpp:46:17: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/10/sstream:38, from /usr/include/c++/10/complex:45, from /usr/include/c++/10/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54, from furniture.cpp:1: /usr/include/c++/10/istream:120:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' 120 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/10/istream:120:36: note: no known conversion for argument 1 from 'std::bitset<1005>::reference' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 120 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/10/istream:124:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]' 124 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/10/istream:124:32: note: no known conversion for argument 1 from 'std::bitset<1005>::reference' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 124 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/10/istream:131:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]' 131 | operator>>(ios_base& (*__pf)(ios_base&)) | ^~~~~~~~ /usr/include/c++/10/istream:131:30: note: no known conversion for argument 1 from 'std::bitset<1005>::reference' to 'std::ios_base& (*)(std::ios_base&)' 131 | operator>>(ios_base& (*__pf)(ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/10/istream:235:7: note: candidate: 'std::bas