답안 #757579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757579 2023-06-13T11:20:57 Z Hanksburger Furniture (JOI20_furniture) C++17
5 / 100
5000 ms 10148 KB
#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[2]={{1, 0}, {0, 1}};
int a[1005][1005], visited[1005][1005];
queue<pair<int, int> > q;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, o;
    cin >> n >> m;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin >> a[i][j];
    cin >> o;
    for (int i=1; i<=o; i++)
    {
        int x, y;
        cin >> x >> y;
        a[x][y]=1;
        for (int j=1; j<=n; j++)
            for (int k=1; k<=m; k++)
                visited[j][k]=0;
        visited[1][1]=1;
        q.push({1, 1});
        while (!q.empty())
        {
            int ux=q.front().first, uy=q.front().second;
            q.pop();
//            cout << "ux uy " << ux << ' ' << uy << '\n';
            for (int j=0; j<2; j++)
            {
                int vx=ux+p[j].first, vy=uy+p[j].second;
                if (1<=vx && vx<=n && 1<=vy && vy<=m && !visited[vx][vy] && !a[vx][vy])
                {
                    visited[vx][vy]=1;
                    q.push({vx, vy});
                }
            }
        }
        if (!visited[n][m])
            a[x][y]=0;
        cout << a[x][y] << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 852 KB Output is correct
2 Correct 29 ms 1108 KB Output is correct
3 Correct 113 ms 980 KB Output is correct
4 Correct 181 ms 1184 KB Output is correct
5 Correct 202 ms 1108 KB Output is correct
6 Correct 341 ms 1228 KB Output is correct
7 Correct 129 ms 1108 KB Output is correct
8 Correct 174 ms 1108 KB Output is correct
9 Correct 443 ms 1248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 852 KB Output is correct
2 Correct 29 ms 1108 KB Output is correct
3 Correct 113 ms 980 KB Output is correct
4 Correct 181 ms 1184 KB Output is correct
5 Correct 202 ms 1108 KB Output is correct
6 Correct 341 ms 1228 KB Output is correct
7 Correct 129 ms 1108 KB Output is correct
8 Correct 174 ms 1108 KB Output is correct
9 Correct 443 ms 1248 KB Output is correct
10 Correct 4950 ms 960 KB Output is correct
11 Correct 196 ms 780 KB Output is correct
12 Execution timed out 5022 ms 10148 KB Time limit exceeded
13 Halted 0 ms 0 KB -