3 solutions

  • 1
    @ 2024-4-8 11:18:28

    #include using namespace std;

    int W,X,H;

    bool a[25][25][25]; int q,x1,y1,z1,x2,y2,z2;

    int main(){ cin >> W >> X >> H; for (int i=1;i<=W;i++) for (int j=1;j<=X;j++) for (int k=1;k<=H;k++) a[i][j][k] = 1; cin >> q; while (q--){ cin >> x1 >> y1 >>z1 >> x2 >> y2 >> z2;

    for (int i=x1;i<=x2;i++)
    	for (int j=y1;j<=y2;j++)
    	for (int k=z1;k<=z2;k++)
    		a[i][j][k] = 0;
    }	
    int ans = 0;
    for (int i=1;i<=W;i++)
    for (int j=1;j<=X;j++)
    for (int k=1;k<=H;k++)
    	if (a[i][j][k] == 1) ans++;
    cout << ans;
    

    Copy

    }

    • 0
      @ 2024-4-1 22:42:49

      #include <bits/stdc++.h> using namespace std; const int N = 25; int a[N][N][N]; int main() { int w, x, h, q; cin >> w >> x >> h >> q; int x1, y1, z1, x2, y2, z2, ans = 0; while (q--) { cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2; for (int i = x1; i <= x2; i++) for (int j = y1; j <= y2; j++) for (int k = z1; k <= z2; k++) a[i][j][k] = 1;//逆向思维 } //计算剩余块数量 for (int i = 1; i <= w; ++i) for (int j = 1; j <= x; ++j) for (int k = 1; k <= h; ++k) if (!a[i][j][k])ans++; cout << ans << endl; return 0; }

      • -1
        @ 2024-4-8 11:13:15

        #include using namespace std;

        int W,X,H;

        bool a[25][25][25]; int q,x1,y1,z1,x2,y2,z2;

        int main(){ cin >> W >> X >> H; for (int i=1;i<=W;i++) for (int j=1;j<=X;j++) for (int k=1;k<=H;k++) a[i][j][k] = 1; cin >> q; while (q--){ cin >> x1 >> y1 >>z1 >> x2 >> y2 >> z2;

        for (int i=x1;i<=x2;i++)
        	for (int j=y1;j<=y2;j++)
        	for (int k=z1;k<=z2;k++)
        		a[i][j][k] = 0;
        }	
        int ans = 0;
        for (int i=1;i<=W;i++)
        for (int j=1;j<=X;j++)
        for (int k=1;k<=H;k++)
        	if (a[i][j][k] == 1) ans++;
        cout << ans;
        

        }

        • 1

        Information

        ID
        4694
        Time
        1000ms
        Memory
        125MiB
        Difficulty
        1
        Tags
        (None)
        # Submissions
        83
        Accepted
        43
        Uploaded By