QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345498 | #7733. Cool, It’s Yesterday Four Times More | Sorting# | Compile Error | / | / | C++14 | 3.0kb | 2024-03-07 01:34:10 | 2024-03-07 01:34:10 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <bitset>
#include <stack>
#include <utility>
using namespace std;
const int N = 1000 + 3;
int n, m;
string s[N];
bitset<N> b[N];
vector<int> pos[2 * N][2 * N];
bool vis[N][N];
vector<pair<int, int>> get_posi(int sx, int sy){
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
vis[i][j] = false;
}
}
stack<pair<int, int>> st;
st.push({sx, sy});
vis[sx][sy] = true;
while(!st.empty()){
auto [x2, y2] = st.top();
st.pop();
const static pair<int, int> adj[4]{{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
for(auto [dx, dy]: adj){
auto [to_x, to_y] = pair{x2 + dx, y2 + dy};
if(to_x < 0 || to_y < 0 || n <= to_x || m <= to_y){
continue;
}
if(vis[to_x][to_y]) continue;
if(s[to_x][to_y] == 'O') continue;
vis[to_x][to_y] = true;
st.push({to_x, to_y});
}
}
vector<pair<int, int>> ans;
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
if(vis[i][j] && (i != sx || j != sy)){
ans.push_back({i - sx, j - sy});
}
}
}
return ans;
}
void solve(){
cin >> n >> m;
for(int i = 0; i < n; ++i)
cin >> s[i];
for(int i = 0; i < n * m; ++i)
b[i].reset();
int cnt_players = 0;
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
if(s[i][j] == 'O') continue;
auto v = get_posi(i, j);
++cnt_players;
for(auto [x, y]: v){
// cout << x << " " << y << " x y " << i << " " << j << endl;
pos[x + N][y + N].push_back(i * m + j);
}
}
}
static bitset<N> curr;
curr.reset();
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
if(s[i][j] == 'O') continue;
curr[i * m + j] = true;
}
}
for(int i = -n; i <= n; ++i){
for(int j = -m; j <= m; ++j){
if(pos[i + N][j + N].empty()) continue;
for(int x: pos[i + N][j + N]){
curr[x] = 0;
}
for(int x: pos[i + N][j + N]){
b[x] |= curr;
// cout << x << " - " << i << " " << j << endl;
}
for(int x: pos[i + N][j + N]){
curr[x] = 1;
}
pos[i + N][j + N].clear();
}
}
int ans = 0;
for(int i = 0; i < n * m; ++i){
if(s[i / m][i % m] == 'O') continue;
ans += b[i].count() == cnt_players - 1;
}
cout << ans << "\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--){
solve();
}
}
Details
answer.code: In function ‘std::vector<std::pair<int, int> > get_posi(int, int)’: answer.code:37:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 37 | auto [x2, y2] = st.top(); | ^ answer.code:41:18: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 41 | for(auto [dx, dy]: adj){ | ^ answer.code:42:18: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 42 | auto [to_x, to_y] = pair{x2 + dx, y2 + dy}; | ^ answer.code:42:37: error: missing template arguments before ‘{’ token 42 | auto [to_x, to_y] = pair{x2 + dx, y2 + dy}; | ^ answer.code:42:37: error: expected ‘;’ before ‘{’ token answer.code:49:20: error: no matching function for call to ‘std::stack<std::pair<int, int> >::push(<brace-enclosed initializer list>)’ 49 | st.push({to_x, to_y}); | ~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/13/stack:63, from answer.code:11: /usr/include/c++/13/bits/stl_stack.h:260:7: note: candidate: ‘void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]’ 260 | push(const value_type& __x) | ^~~~ /usr/include/c++/13/bits/stl_stack.h:260:30: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::stack<std::pair<int, int> >::value_type&’ {aka ‘const std::pair<int, int>&’} 260 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/13/bits/stl_stack.h:265:7: note: candidate: ‘void std::stack<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; value_type = std::pair<int, int>]’ 265 | push(value_type&& __x) | ^~~~ /usr/include/c++/13/bits/stl_stack.h:265:25: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘std::stack<std::pair<int, int> >::value_type&&’ {aka ‘std::pair<int, int>&&’} 265 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ answer.code: In function ‘void solve()’: answer.code:78:22: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 78 | for(auto [x, y]: v){ | ^