返回列表 發帖
  1. package com.brixpert.dab;

  2. import java.io.*;
  3. public class B965 {
  4.         B965()
  5.         {
  6.                 StreamTokenizer sti = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
  7.             PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
  8.             try
  9.             {
  10.                     while(sti.nextToken() != StreamTokenizer.TT_EOF)
  11.                     {
  12.                             int h,w,f,tmp;
  13.                             h = (int)sti.nval;
  14.                             sti.nextToken();
  15.                             w = (int)sti.nval;
  16.                             sti.nextToken();
  17.                             f = (int)sti.nval;
  18.                             int n[][] = new int[h][w];
  19.                             int nf[] = new int[f];
  20.                             for(int i = 0; i < h; i++)
  21.                             {
  22.                                     for(int j = 0; j < w; j++)
  23.                                 {
  24.                                             sti.nextToken();
  25.                                         n[i][j] = (int)sti.nval;
  26.                                 }
  27.                             }
  28.                             for(int i = 0; i < f; i++)
  29.                             {
  30.                                         sti.nextToken();
  31.                                     nf[i] = (int)sti.nval;
  32.                             }
  33. //-------------------------------------------------------------------------------------------------
  34.                             for(int r = f-1; r >= 0; r--)
  35.                             {
  36.                                     if(nf[r] == 1)
  37.                                     {
  38.                                             //flip
  39.                                             int x[][] = new int[h][w];
  40.                                     for(int i = 0; i < h; i++)
  41.                                     {
  42.                                             for(int j = 0; j < w; j++)
  43.                                         {
  44.                                                     x[i][j] = n[h-1-i][j];
  45.                                         }
  46.                                     }
  47.                                     n = x;
  48.                                     }
  49.                                     else
  50.                                     {
  51.                                             //turn
  52.                                             int x[][] = new int[w][h];
  53.                                             for(int i = 0; i < w; i++)
  54.                                     {
  55.                                             for(int j = 0; j < h; j++)
  56.                                         {
  57.                                                     x[i][j] = n[j][w-1-i];
  58.                                         }
  59.                                     }
  60.                                     tmp = h;
  61.                                     h = w;
  62.                                     w = tmp;
  63.                                     n = x;
  64.                                     }                              
  65.                             }
  66.                             //output
  67.                             pw.print(h+" "+w+"\n");
  68.                             for(int i = 0; i < h; i++)
  69.                         {
  70.                                 for(int j = 0; j < w; j++)
  71.                             {
  72.                                         if(j != 0)
  73.                                                 pw.print(" ");
  74.                                         pw.print(n[i][j]);
  75.                             }
  76.                                 pw.println();
  77.                         }
  78.                         pw.flush();
  79.                     }
  80.             }catch(Exception exc)
  81.             {
  82.                     pw.print(exc.toString());
  83.                     pw.flush();
  84.             }
  85.         }
  86.         public static void main(String[] args) {
  87.                 // TODO 自動產生的方法 Stub
  88.         new B965();
  89.         }

  90. }
  91. /*
  92.   ____   ___    __ _____                                                                                          
  93. |  _ \ / _ \  / /| ____|                                                                                         
  94. | |_) | (_) |/ /_| |__                                                                                          
  95. |  _ < \__, | '_ \___ \                                                                                          
  96. | |_) |  / /| (_) |__) |                                                                                         
  97. |____/  /_/  \___/____/       ____  _____  ___   _______  ______ _____ _______ ______ ___  __ _  _               
  98. | |           |  __ \   /\   |  _ \|  __ \(_) \ / /  __ \|  ____|  __ \__   __|____  / _ \/_ | || |              
  99. | |__  _   _  | |  | | /  \  | |_) | |__) |_ \ V /| |__) | |__  | |__) | | |      / / | | || | || |_            
  100. | '_ \| | | | | |  | |/ /\ \ |  _ <|  _  /| | > < |  ___/|  __| |  _  /  | |     / /| | | || |__   _|            
  101. | |_) | |_| | | |__| / ____ \| |_) | | \ \| |/ . \| |    | |____| | \ \  | |    / / | |_| || |  | |              
  102. |_.__/ \__, | |_____/_/    \_\____/|_|  \_\_/_/ \_\_|    |______|_|  \_\ |_|   /_/   \___/ |_|  |_|              
  103.          __/ |                                                                                                   
  104.         |___/ ___   ___  __  ___  __ ___    ___   ___    __  ___    _____  ___   _______ __  __ _______    _____  
  105.        | |   |__ \ / _ \/_ |/ _ \/_ |__ \  |__ \ / _ \  /_ |/ _ \ _| ____|/ _ \ / / ____|  \/  |__   __|  / _ \ \
  106.    __ _| |_     ) | | | || | (_) || |  ) |    ) | (_) |  | | (_) (_) |__ | (_) | | |  __| \  / |  | |_| || (_) | |
  107.   / _` | __|   / /| | | || |\__, || | / /    / / > _ <   | |\__, | |___ \ > _ <| | | |_ | |\/| |  | |_   _> _ <| |
  108. | (_| | |_   / /_| |_| || |  / / | |/ /_ _ / /_| (_) |  | |  / / _ ___) | (_) | | |__| | |  | |  | | |_|| (_) | |
  109.   \__,_|\__| |____|\___/ |_| /_(_)|_|____(_)____|\___/   |_| /_/ (_)____/ \___/| |\_____|_|  |_|  |_|     \___/| |
  110.                                                                                 \_\                           /_/
  111.                                                                                                                   
  112. */
複製代碼
https://www.facebook.com/DABRiXPERT6584

TOP

返回列表