Submission #427913

#TimeUsernameProblemLanguageResultExecution timeMemory
427913cfalasFurniture (JOI20_furniture)C++14
5 / 100
5096 ms1140 KiB
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define INF 10000000 #define MOD 1000000007 #define MID ((l+r)/2) #define HASHMOD 2305843009213693951 #define ll long long #define ull unsigned long long #define F first #define S second typedef pair<ll, ll> ii; typedef pair<ii, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef map<int, int> mii; #define EPS 1e-6 #define FOR(i,n) for(int i=0;i<((int)(n));i++) #define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++) #define FOA(v, a) for(auto v : a) int t, n; vi a, b; int main(){ int n, m; cin>>n>>m; vector<vi> a(n, vi(m)); FOR(i,n){ FOR(j,m) cin>>a[i][j]; } int q; cin>>q; while(q--){ int x,y; cin>>x>>y; vector<vi> b(n, vi(m)); b[0][0] = 1; FORi(i,1,n) b[i][0] = b[i-1][0] && (a[i][0]==0 && !(x-1==i && y==1)); FORi(i,1,m) b[0][i] = b[0][i-1] && (a[0][i]==0 && !(x==1 && i==y-1)); FORi(i,1,n){ FORi(j,1,m){ b[i][j] = b[i-1][j]+b[i][j-1]; if(a[i][j]) b[i][j] = 0; if(i==x-1 && j==y-1) b[i][j] = 0; } } if(b[n-1][m-1]) cout<<1<<endl, a[x-1][y-1] = 1; else cout<<0<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...