Submission #1159454

#TimeUsernameProblemLanguageResultExecution timeMemory
1159454Zero_OPFurniture (JOI20_furniture)C++20
5 / 100
5094 ms7920 KiB
#include <bits/stdc++.h> using namespace std; //loops (warning : long long) #define FOR(i, l, r) for(int i = (l); i < (r); ++i) #define ROF(i, r, l) for(int i = (r - 1); i >= l; --i) //pairs, tuples #define mp make_pair #define mt make_tuple #define ff first #define ss second //vectors #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) #define pb push_back #define eb emplace_back #define sum_of(v) accumulate(all(v), 0ll) #define sz(v) (int)v.size() #define compact(v) v.erase(unique(all(v)), end(v)) //binary search #define lwb lower_bound #define upb upper_bound //other stuffs #define dbg(x) "[" #x " = " << (x) << "]" #define file(task) if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } template<typename T> bool minimize(T& a, const T& b){ if(a > b) return a = b, true; return false; } template<typename T> bool maximize(T& a, const T& b){ if(a < b) return a = b, true; return false; } using ll = long long; using ull = unsigned long long; using ld = long double; using db = double; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vb = vector<bool>; using vl = vector<ll>; using vpi = vector<pi>; using vpl = vector<pl>; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAX = 5e5 + 5; void testcase(int ntestcase){ int N, M; cin >> N >> M; vector<vi> a(N, vi(M)); FOR(i, 0, N){ FOR(j, 0, M){ cin >> a[i][j]; } } vector<vi> dp(N, vi(M)); auto can = [&](){ dp[0][0] = 1; FOR(i, 0, N){ FOR(j, (i == 0), M){ dp[i][j] = 0; if(a[i][j] == 1) continue; if(i > 0) dp[i][j] |= dp[i-1][j]; if(j > 0) dp[i][j] |= dp[i][j-1]; } } return dp[N-1][M-1]; }; int Q; cin >> Q; while(Q--){ int x, y; cin >> x >> y; --x, --y; a[x][y] = 1; bool ok = can(); if(!ok) a[x][y] = 0; cout << ok << '\n'; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef LOCAL freopen("task.inp", "r", stdin); freopen("task.ans", "w", stdout); #endif // LOCAL int T = 1; // cin >> T; FOR(i, 0, T) testcase(i); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...