Submission #734145

#TimeUsernameProblemLanguageResultExecution timeMemory
734145n0sk1llFurniture (JOI20_furniture)C++17
100 / 100
290 ms13900 KiB
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0) #define mp make_pair #define xx first #define yy second #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define all(x) x.begin(),x.end() #define ff(i,a,b) for (int i = a; i < b; i++) #define fff(i,a,b) for (int i = a; i <= b; i++) #define bff(i,a,b) for (int i = b-1; i >= a; i--) #define bfff(i,a,b) for (int i = b; i >= a; i--) using namespace std; long double typedef ld; unsigned int typedef ui; long long int typedef li; pair<int,int> typedef pii; pair<li,li> typedef pli; pair<ld,ld> typedef pld; vector<vector<int>> typedef graph; unsigned long long int typedef ull; //const int mod = 998244353; const int mod = 1000000007; //Note to self: Check for overflow bool c1[1003][1003]; //blokiran za gornji levi cosak? bool c2[1003][1003]; //blokiran za dodnji desni cosak? int slob[2006]; //koliko slobodnih na datoj dijagonali void Put1(int x, int y) { if (c1[x][y]) return; if (!c2[x][y]) slob[x+y]--; c1[x][y]=1; if (c1[x-1][y+1]) Put1(x,y+1); if (c1[x+1][y-1]) Put1(x+1,y); } void Put2(int x, int y) { if (c2[x][y]) return; if (!c1[x][y]) slob[x+y]--; c2[x][y]=1; if (c2[x-1][y+1]) Put2(x-1,y); if (c2[x+1][y-1]) Put2(x,y-1); } int main() { FAST; int n,m; cin>>n>>m; fff(i,0,n+1) fff(j,0,m+1) c1[i][j]=1,c2[i][j]=1; fff(i,1,n) fff(j,1,m) slob[i+j]++,c1[i][j]=0,c2[i][j]=0; fff(i,1,n) fff(j,1,m) { bool sta; cin>>sta; if (sta) Put1(i,j),Put2(i,j); } int q; cin>>q; while (q--) { int x,y; cin>>x>>y; if (c1[x][y] || c2[x][y] || slob[x+y]>1) Put1(x,y),Put2(x,y),cout<<1<<"\n"; else cout<<0<<"\n"; } } //Note to self: Check for overflow
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...