2 条题解

  • 0
    @ 2023-11-9 12:12:22
    #include<iostream>
    using namespace std;
    
    int main()
    {
    	int m,n;
    	cin >> m >> n;
    	int k[m][n];
    	int max=0;
    	for(int i=0;i<m;i++)
    	{
    		int u=0;
    		for(int j=0;j<n;j++)
    		{
    			cin >>k[i][j];
    			if(k[i][j]>u)
    				u=k[i][j];
    		}
    		if(3*u+3+(m-1-i)*2>max)
    			max=3*u+3+(m-1-i)*2;
    	}
    	int a=max;
    	int b=4*n+1+2*m;
    	char gra[a][b];
    	for(int i=0;i<a;i++)
    	{
    		for(int j=0;j<b;j++)
    		{
    			gra[i][j]='.';
    		}
    	}
    
    	for(int i=0;i<m;i++)
    	{
    		for(int j=0;j<n;j++)
    		{
    			for(int w=0;w<k[i][j];w++)
    			{
    				int x[2];
    		 		int y[2];
    				x[0]=a-1-2*(m-i-1)-3*w;
    				y[0]=2*(m-i-1)+4*j;
    				x[1]=x[0]-2;
    				y[1]=y[0]+2;
    				for(int r=1;r>=0;r--)
    				{
    					gra[x[r]][y[r]]='+';
    					gra[x[r]][y[r]+4]='+';
    					gra[x[r]-3][y[r]]='+';
    					gra[x[r]-3][y[r]+4]='+';
    					gra[x[r]][y[r]+1]='-';
    					gra[x[r]][y[r]+2]='-';
    					gra[x[r]][y[r]+3]='-';
    					gra[x[r]-3][y[r]+1]='-';
    					gra[x[r]-3][y[r]+2]='-';
    					gra[x[r]-3][y[r]+3]='-';
    					gra[x[r]-1][y[r]]='|';
    					gra[x[r]-2][y[r]]='|';
    					gra[x[r]-1][y[r]+4]='|';
    					gra[x[r]-2][y[r]+4]='|';
    					gra[x[r]-2][y[r]+1]=' ';
    					gra[x[r]-2][y[r]+2]=' ';
    					gra[x[r]-2][y[r]+3]=' ';
    					gra[x[r]-1][y[r]+1]=' ';
    					gra[x[r]-1][y[r]+2]=' ';
    					gra[x[r]-1][y[r]+3]=' ';
    				}
    				gra[x[0]-4][y[0]+1]='/';
    				gra[x[0]-4][y[0]+2]=' ';
    				gra[x[0]-4][y[0]+3]=' ';
    				gra[x[0]-4][y[0]+4]=' ';
    				gra[x[0]-4][y[0]+5]='/';
    				gra[x[0]-3][y[0]+5]=' ';
    				gra[x[0]-2][y[0]+5]=' ';
    				gra[x[0]-1][y[0]+5]='/';
    			}
    		}
    	}
    	for(int i=0;i<a;i++)
    	{
    		for(int j=0;j<b;j++)
    		{
    			cout << gra[i][j];
    		}
    		cout << endl;
    	}
    	return 0;
     }
    
    • 0
      @ 2023-9-27 11:05:03
      import java.util.Scanner;
      
      public class Main {
          public static void main(String[] args) {
              final Scanner scanner = new Scanner(System.in);
              final int m = scanner.nextInt(), n = scanner.nextInt();
              final int[][] cachedJuXing = new int[m][n];
              int maxX = 0, maxY = 0;
              for (int i = 0; i < m; i++) {
                  for (int j = 0; j < n; j++) {
                      int amount = scanner.nextInt();
                      cachedJuXing[i][j] = amount;
                  }
              }
              for (int i = 0; i < m; i++) {
                  int startX = (m - 1 - i) * 2, startY = (m - 1 - i) * 2;
                  for (int j = 0; j < n; j++) {
                      int amount = cachedJuXing[i][j];
                      if (amount <= 0) continue;
                      int x = startX + (j * 4) + 7;
                      int y = startY + ((amount - 1) * 3) + 6;
                      if (x > maxX) maxX = x;
                      if (y > maxY) maxY = y;
                  }
              }
              final int[][] juXing = new int[maxY][maxX];
              int index = 0;
              for (int i = 0; i < n; i++) {
                  for (int j = 0; j < m; j++) {
                      index++;
                      int amount = cachedJuXing[j][i];
                      if (amount <= 0) continue;
                      int startY = maxY - 1 - ((m - 1 - j) * 2), startX = (m - 1 - j) * 2;
                      for (int k = 0; k < amount; k++) {
                          int a = startY - (k * 3), b = startX + (i * 4);
                          buildJuXing(juXing, a, b);
                      }
                  }
              }
              for (int[] ints : juXing) {
                  for (int value : ints) {
                      if (value == 0) {
                          System.out.print(".");
                          continue;
                      }
                      System.out.print((char) value);
                  }
                  System.out.println();
              }
          }
      
          public static void buildJuXing(int[][] intArray, int leftCornerY, int leftCornerX) {
              //leftCorner
              intArray[leftCornerY][leftCornerX] = 43;
              //leftTop
              intArray[leftCornerY - 3][leftCornerX] = 43;
              //leftTopTop
              intArray[leftCornerY - 5][leftCornerX + 2] = 43;
              //rightCorner
              intArray[leftCornerY][leftCornerX + 4] = 43;
              //rightTop
              intArray[leftCornerY - 3][leftCornerX + 4] = 43;
              //rightTopTop
              intArray[leftCornerY - 5][leftCornerX + 6] = 43;
              //rightCornerCorner
              intArray[leftCornerY - 2][leftCornerX + 6] = 43;
      
              //twoLine
              intArray[leftCornerY - 1][leftCornerX] = 124;
              intArray[leftCornerY - 2][leftCornerX] = 124;
              intArray[leftCornerY - 1][leftCornerX + 4] = 124;
              intArray[leftCornerY - 2][leftCornerX + 4] = 124;
              intArray[leftCornerY - 4][leftCornerX + 6] = 124;
              intArray[leftCornerY - 3][leftCornerX + 6] = 124;
      
              //flatLine
              intArray[leftCornerY][leftCornerX + 1] = 45;
              intArray[leftCornerY][leftCornerX + 2] = 45;
              intArray[leftCornerY][leftCornerX + 3] = 45;
              intArray[leftCornerY - 3][leftCornerX + 1] = 45;
              intArray[leftCornerY - 3][leftCornerX + 2] = 45;
              intArray[leftCornerY - 3][leftCornerX + 3] = 45;
              intArray[leftCornerY - 5][leftCornerX + 3] = 45;
              intArray[leftCornerY - 5][leftCornerX + 4] = 45;
              intArray[leftCornerY - 5][leftCornerX + 5] = 45;
      
              //bankLine
              intArray[leftCornerY - 4][leftCornerX + 1] = 47;
              intArray[leftCornerY - 4][leftCornerX + 5] = 47;
              intArray[leftCornerY - 1][leftCornerX + 5] = 47;
      
              //blank
              intArray[leftCornerY - 1][leftCornerX + 1] = 32;
              intArray[leftCornerY - 2][leftCornerX + 1] = 32;
              intArray[leftCornerY - 1][leftCornerX + 2] = 32;
              intArray[leftCornerY - 2][leftCornerX + 2] = 32;
              intArray[leftCornerY - 1][leftCornerX + 3] = 32;
              intArray[leftCornerY - 2][leftCornerX + 3] = 32;
              intArray[leftCornerY - 4][leftCornerX + 2] = 32;
              intArray[leftCornerY - 4][leftCornerX + 3] = 32;
              intArray[leftCornerY - 4][leftCornerX + 4] = 32;
              intArray[leftCornerY - 2][leftCornerX + 5] = 32;
              intArray[leftCornerY - 3][leftCornerX + 5] = 32;
          }
      }
      
      • 1

      信息

      ID
      464
      时间
      1000ms
      内存
      50MiB
      难度
      6
      标签
      递交数
      95
      已通过
      32
      上传者