考场上开long long会不会爆0

P11228 [CSP-J 2024] 地图探险

tanzili @ 2024-10-27 15:58:51

洛谷上开long long爆0了,但改int后就AC了


by ZMQ_Ink6556 @ 2024-10-27 15:59:32

代码?


by tanzili @ 2024-10-27 16:16:58

#include<bits/stdc++.h>
using namespace std;
long long ans,t,n,m,k,x,y,d,nx[4]={0,1,0,-1},ny[4]={1,0,-1,0},aa[10001][10001];
char a[10001][10001];
void dfs(int xx,int yy,int dd)
{
    if(a[xx+nx[dd]][yy+ny[dd]]=='.')
    {
        x=xx+nx[dd],y=yy+ny[dd];
        if(!aa[x][y])
        {
            aa[x][y]=1;
            ans++;
        }
    }
    else 
    d=(dd+1)%4;
}
int main()
{
    cin>>t;
    while(t--)
    {
        ans=1;
        memset(aa,0,sizeof(aa));
        memset(a,0,sizeof(a));
        cin>>n>>m>>k>>x>>y>>d;
        aa[x][y]=1;
        for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) 
        {
            cin>>a[i][j];
        }
        for(int i=1;i<=k;i++)
        {
            dfs(x,y,d);
        }
        cout<<ans<<endl;
    }
    return 0;
}

by h_a_s_h_a_w_a @ 2024-10-27 16:44:03

不会) 但我在考场上漏了k--这T当场爆零(?)


by h_a_s_h_a_w_a @ 2024-10-27 16:45:16

除非你开了肥肠大的数组) 这道题1005*1005不至于吧....


|