Submission #500795

# Submission time Handle Problem Language Result Execution time Memory
500795 2022-01-01T09:40:55 Z AmirElarbi Furniture (JOI20_furniture) C++14
5 / 100
5000 ms 4276 KB
#include <bits/stdc++.h>
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 1e9
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9+7;
const int nax = 200005;
bool grid[1005][1005],vis[1005][1005];
int n,m;
bool dfs(int x, int y){
    if(x == n-1 && y == m-1) return 1;
    if(x >= n || y >= m) return 0;
    if(grid[x][y]) return 0;
    if(vis[x][y]) return 0;
    vis[x][y] = 1;
    return max(dfs(x+1,y),dfs(x,y+1));
}
int main(){
    optimise;

    cin>>n >>m;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            cin >> grid[i][j];
        }
    }
    int q;
    cin >>q;
    while(q--){
        int x,y;
        cin >> x >> y;
        x--,y--;
        grid[x][y] = 1;
        memset(vis,0,sizeof vis);
        int a = dfs(0,0);
        cout << a << '\n';
        grid[x][y] = a;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1356 KB Output is correct
2 Correct 90 ms 1348 KB Output is correct
3 Correct 149 ms 1484 KB Output is correct
4 Correct 282 ms 1356 KB Output is correct
5 Correct 300 ms 1464 KB Output is correct
6 Correct 423 ms 1484 KB Output is correct
7 Correct 284 ms 1464 KB Output is correct
8 Correct 357 ms 1484 KB Output is correct
9 Correct 445 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1356 KB Output is correct
2 Correct 90 ms 1348 KB Output is correct
3 Correct 149 ms 1484 KB Output is correct
4 Correct 282 ms 1356 KB Output is correct
5 Correct 300 ms 1464 KB Output is correct
6 Correct 423 ms 1484 KB Output is correct
7 Correct 284 ms 1464 KB Output is correct
8 Correct 357 ms 1484 KB Output is correct
9 Correct 445 ms 1484 KB Output is correct
10 Correct 3571 ms 1696 KB Output is correct
11 Correct 256 ms 1484 KB Output is correct
12 Execution timed out 5026 ms 4276 KB Time limit exceeded
13 Halted 0 ms 0 KB -