3 条题解

  • 2
    @ 2023-11-10 22:32:11
    #include <iostream>
    int main(){     //[k]天 [i]x [j]y
        int n,m,sum=0;char a[105][105][105]; std::cin>>n;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                std::cin>>a[1][i][j];
        std::cin>>m;
        for(int k=1;k<=m;k++){
            for(int i=1;i<=n;i++){
                for(int j=1;j<=n;j++){
                    if(a[k-1][i][j]=='#')a[k][i][j]='#';
                    else if(a[k-1][i][j]=='@'||
                            a[k-1][i-1][j]=='@'||
                            a[k-1][i][j-1]=='@'||
                            a[k-1][i+1][j]=='@'||
                            a[k-1][i][j+1]=='@')
                            a[k][i][j]='@';}}}
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                sum+=a[m][i][j]=='@'?1:0;
        std::cout<<sum; return 0;}
    
    • 0
      @ 2023-12-9 20:45:15
      #include<iostream>
      int n,m;
      char g[101][101][101];
      int main()
      {
          std::cin>>n;
          for(int i=1;i<=n;i+=1)for(int j=1;j<=n;j+=1)std::cin>>g[1][i][j];
          std::cin>>m;
          for(int day=2;day<=m;day+=1)for(int i=1;i<=n;i+=1)for(int j=1;j<=n;j+=1)if(g[day-1][i][j]=='#')g[day][i][j]='#';else if(g[day-1][i-1][j]=='@'||g[day-1][i][j-1]=='@'||g[day-1][i][j]=='@'||g[day-1][i][j+1]=='@'||g[day-1][i+1][j]=='@')g[day][i][j]='@';
          int cnt=0;
          for(int i=1;i<=n;i+=1)for(int j=1;j<=n;j+=1)if(g[m][i][j]=='@')cnt+=1;
          std::cout<<cnt<<"\n";
      }
      
      • 0
        @ 2023-11-22 18:35:43

        很暴力

        #include <bits/stdc++.h>
        using namespace std;
        int main()
        {
            int n, m, ans = 0;
            char a[105][105];
            cin >> n;
            for (int i = 1; i <= n; i++)
                for (int j = 1; j <= n; j++)
                    cin >> a[i][j];
            cin >> m;
            m--;
            while(m--)
            {
                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <= n; j++)
                    {
                        if (a[i][j] == '@' && a[i + 1][j] == '.')
                            a[i + 1][j] = '!';
                        if (a[i][j] == '@' && a[i - 1][j] == '.')
                            a[i - 1][j] = '!';
                        if (a[i][j] == '@' && a[i][j + 1] == '.')
                            a[i][j + 1] = '!';
                        if (a[i][j] == '@' && a[i][j - 1] == '.')
                            a[i][j - 1] = '!';
                    }
                }
                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <= n; j++)
                        if (a[i][j] == '!')
                            a[i][j] = '@';
                }
                /*
                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <= n; j++)
                        cout << a[i][j];
                    cout << endl;
                }
                cout << endl;
                */
            }
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                    if (a[i][j] == '@')
                        ans++;
            }
            cout << ans << endl;
            return 0;
        }
        
        • 1

        信息

        ID
        569
        时间
        1000ms
        内存
        256MiB
        难度
        5
        标签
        递交数
        759
        已通过
        277
        上传者