제출 #467711

#제출 시각아이디문제언어결과실행 시간메모리
467711stefantagaFurniture (JOI20_furniture)C++14
0 / 100
19 ms1484 KiB
#include <bits/stdc++.h> #define MOD1 1000000007 #define MOD2 1000000013 using namespace std; int n,m,i,j,k,t,q,x,y,val,val2; int v[1005][1005],din[1005][1005],din2[1005][1005]; int main() { ios_base :: sync_with_stdio(false); cin.tie(0); #ifdef HOME ifstream cin("date.in"); ofstream cout("date.out"); #endif // HOME cin>>n>>m; for (i=1; i<=n; i++) { for (j=1; j<=m; j++) { cin>>v[i][j]; } } din[1][1]=din2[1][1]=1; for (i=1; i<=n; i++) { for (j=1; j<=m; j++) { din[i][j]=(din[i][j]+din[i-1][j]+din[i][j-1])%MOD1; din2[i][j]=(din2[i][j]+din2[i-1][j]+din2[i][j-1])%MOD2; } } for (i=1; i<=n; i++) { for (j=1; j<=m; j++) { if (v[i][j]==1) { val=din[i][j]; val2=din2[i][j]; for (k=i; k<=n; k++) { for (t=j; t<=m; t++) { din[k][t]=(din[k][t]-val+MOD1)%MOD1; din2[k][t]=(din2[k][t]-val2+MOD2)%MOD2; } } } } } cin>>q; for (i=1; i<=q; i++) { cin>>x>>y; if (x==1&&y==1) { cout<<"0"<<'\n'; continue; } if ((din[n][m]-din[x][y]+MOD1)%MOD1!=0&&(din2[n][m]-din2[x][y]+MOD2)%MOD2!=0) { cout<<"1"<<'\n'; val=din[x][y]; val2=din2[x][y]; for (k=x; k<=n; k++) { for (t=y; t<=m; t++) { din[k][t]=(din[k][t]-val+MOD1)%MOD1; din2[k][t]=(din2[k][t]-val2+MOD2)%MOD2; } } } else { cout<<"0"<<'\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...