| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 423570 | Kerim | Furniture (JOI20_furniture) | C++17 | 488 ms | 15756 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 MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=1002;
int vis[N][N],dgn[N+N],n,m;
stack<PII>st;
void upd(int x,int y){
if(!vis[x][y]){
dgn[x+y]--;
vis[x][y]=1;
st.push(mp(x,y));
}
}
void check(int x,int y){
if(vis[x][y] and vis[x+1][y-1]){
upd(x,y-1);
upd(x+1,y);
}
}
int mark(int x,int y){
if(vis[x][y])return 1;
if(dgn[x+y]==1)return 0;
upd(x,y);
while(!st.empty()){
int x=st.top().ff;
int y=st.top().ss;
st.pop();
check(x-1,y+1);
check(x,y);
}
return 1;
}
int main(){
//~ freopen("file.in", "r", stdin);
scanf("%d%d",&n,&m);
for(int i=0;i<=n+1;i++)
for(int j=0;j<=m+1;j++){
if(!j or !i or i>n or j>m)vis[i][j]=1;
else dgn[i+j]++;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
int x;
scanf("%d",&x);
if(x)assert(mark(i,j));
}
int q;
scanf("%d",&q);
while(q--){
int x,y;
scanf("%d%d",&x,&y);
printf("%d\n",mark(x,y));
}
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
