답안 #866959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866959 2023-10-27T13:54:55 Z edogawa_something Furniture (JOI20_furniture) C++17
5 / 100
5000 ms 7352 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define F first 
#define S second 
#define pb push_back
#define all(v) v.begin(),v.end()
const ll M=1001;
ll n,m;
bool a[M][M];
int c[M][M];
bool chk(ll x=0,ll y=0){
    if(x==n-1&&y==m-1)
    return 1;
    if(c[x][y]>-1)
    return c[x][y];
    if(a[x][y])
    return 0;
    bool res=0;
    if(x<n-1)
    res|=chk(x+1,y);
    if(y<m-1)
    res|=chk(x,y+1);
    c[x][y]=res;
    return res;
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)
        cin>>a[i][j];
    }
    ll q;
    cin>>q;
    while(q--){
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++)
            c[i][j]=-1;
        }
        ll x,y;
        cin>>x>>y;
        x--,y--;
        a[x][y]=1;
        if(chk())
        cout<<1<<'\n';
        else{
            cout<<0<<'\n';
            a[x][y]=0;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 4764 KB Output is correct
2 Correct 16 ms 4700 KB Output is correct
3 Correct 72 ms 4768 KB Output is correct
4 Correct 107 ms 4796 KB Output is correct
5 Correct 117 ms 4804 KB Output is correct
6 Correct 222 ms 4808 KB Output is correct
7 Correct 86 ms 4700 KB Output is correct
8 Correct 102 ms 4816 KB Output is correct
9 Correct 270 ms 4832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 4764 KB Output is correct
2 Correct 16 ms 4700 KB Output is correct
3 Correct 72 ms 4768 KB Output is correct
4 Correct 107 ms 4796 KB Output is correct
5 Correct 117 ms 4804 KB Output is correct
6 Correct 222 ms 4808 KB Output is correct
7 Correct 86 ms 4700 KB Output is correct
8 Correct 102 ms 4816 KB Output is correct
9 Correct 270 ms 4832 KB Output is correct
10 Correct 3155 ms 5048 KB Output is correct
11 Correct 123 ms 4788 KB Output is correct
12 Execution timed out 5032 ms 7352 KB Time limit exceeded
13 Halted 0 ms 0 KB -