Submission #516540

# Submission time Handle Problem Language Result Execution time Memory
516540 2022-01-21T12:56:09 Z DJ035 Furniture (JOI20_furniture) C++17
Compilation error
0 ms 0 KB
# pragma GCC optimize ("O3")
# pragma GCC optimize ("Ofast")
# pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define MEM 1111
#define sanic ios_base::sync_with_stdio(0)
#define x first
#define y second
#define pf push_front
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz size()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll MOD = 1e9+7;
const ll INF = 2e14+7;
ll mul(ll a, ll b){
    return ((a*b)%MOD+MOD)%MOD;
}
ll add(ll a, ll b){
    return ((a+b)%MOD+MOD)%MOD;
}

ll t,n,m,q,k;
ll a[MEM][MEM], v[MEM][MEM];
string s;
ll dx[2] = {1,0};
ll dy[2] = {0,1};
queue<pi> q;
ll bfs(){
    memset(v, 0, sizeof(v));
    pi fin={n-1, m-1};
    q.push({0,0});
    while(!q.empty()){
        pi cur = q.front();
        q.pop();
        if(cur==fin)
            return 1;
        //cout << "c " << cur.x << ' ' << cur.y << '\n';
        for(int i=0; i<2; i++){
            ll nx = cur.x+dx[i], ny = cur.y+dy[i];
            //cout <<'\n' << nx << ' ' << ny << ' ';
            if(nx>=n || ny>=m) continue;
            //cout << "p ";
            if(a[nx][ny]) continue;
            if(v[nx][ny]) continue;
            v[nx][ny] = 1;
            //cout << "p ";
            q.push({nx,ny});
        }
    }
    return 0;
}
signed main(){
    sanic; cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            cin >> a[i][j];
    cin >> t;
    while(t--){
        ll q1,q2;
        cin >> q1 >> q2;
        if(a[q1-1][q2-1]){
            cout << 0 << '\n';
            continue;
        }
        a[q1-1][q2-1] = 1;
        ll f=bfs();
        if(f) cout << 1;
        else {
            cout << 0;
            a[q1-1][q2-1] = 0;
        }
        cout << '\n';
    }
}
/*
6
2 3
4 3
1 3
3 5
6 2
110011
*/

Compilation message

furniture.cpp:30:11: error: conflicting declaration 'std::queue<std::pair<long long int, long long int> > q'
   30 | queue<pi> q;
      |           ^
furniture.cpp:25:10: note: previous declaration as 'll q'
   25 | ll t,n,m,q,k;
      |          ^
furniture.cpp: In function 'll bfs()':
furniture.cpp:34:7: error: request for member 'push' in 'q', which is of non-class type 'll' {aka 'long long int'}
   34 |     q.push({0,0});
      |       ^~~~
furniture.cpp:35:14: error: request for member 'empty' in 'q', which is of non-class type 'll' {aka 'long long int'}
   35 |     while(!q.empty()){
      |              ^~~~~
furniture.cpp:36:20: error: request for member 'front' in 'q', which is of non-class type 'll' {aka 'long long int'}
   36 |         pi cur = q.front();
      |                    ^~~~~
furniture.cpp:37:11: error: request for member 'pop' in 'q', which is of non-class type 'll' {aka 'long long int'}
   37 |         q.pop();
      |           ^~~
furniture.cpp:50:15: error: request for member 'push' in 'q', which is of non-class type 'll' {aka 'long long int'}
   50 |             q.push({nx,ny});
      |               ^~~~