这题用cin/cout会挂多少?

P11228 [CSP-J 2024] 地图探险

OIer_Hhy @ 2024-10-28 19:56:09


by OIer_Hhy @ 2024-10-28 19:56:37

没关同步流


by ToMaT @ 2024-10-28 20:00:14

@OIer_Hhy 不会挂


by DHT666 @ 2024-10-28 20:00:50

民间数据没挂分,代码:

#include<bits/stdc++.h>
using namespace std;

const int N = 1010;

int t;
int a[N][N];
int b[N][N];

int main() {
    cin >> t;

    while(t--) {
        int n, m, k, x, y, d;
        cin >> n >> m >> k >> x >> y >> d;

        for(int i = 1;i <= n;i++) {
            for(int j = 1;j <= m;j++) {
                char op;
                cin >> op;
                a[i][j] = op == '.';
                b[i][j] = 0;
            }
        }

        int res = 1;
        b[x][y] = 1;
        for(int i = 1;i <= k;i++) {
            int nx, ny;
            if(d == 0) nx = x, ny = y + 1;
            else if(d == 1) nx = x + 1, ny = y;
            else if(d == 2) nx = x, ny = y - 1;
            else nx = x - 1, ny = y;
            if(a[nx][ny] && nx >= 1 && ny <= m && nx <= n && ny >= 1) {
                x = nx, y = ny;
                res += b[x][y] == 0;
            } else {
                d = (d + 1) % 4;
            }
            b[x][y] = 1;
        }

        cout << res << endl;
    }

    return 0;
}

by Jacky0909 @ 2024-10-28 20:01:29

@OIer_Hhy 这题好像没卡常啊?


by glass_goldfish @ 2024-10-28 20:03:35

@OIer_Hhy 不会s的,O(\sum k) 直接水过去,你看我四题都用cin/cout的,挂了哪题?(T4深搜请不要管,我其实是蒟蒻)


by c23panweiming @ 2024-10-30 13:47:48

@OIer_Hhy 我也是担心这个问题,同问


by czcxyxhycwzy @ 2024-10-30 20:27:29

@DHT666 但是比赛时的大样例cin、cout好像不行


|