zoukankan      html  css  js  c++  java
  • Codeforces Round #601 (Div. 2)D(蛇形模拟)

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 vector<char>ans;
     5 char a[107][107];
     6 int main(){
     7     ios::sync_with_stdio(false);
     8     cin.tie(NULL);
     9     cout.tie(NULL);
    10     for(int i='0';i<='9';++i)
    11         ans.emplace_back(i);
    12     for(int i='A';i<='Z';++i)
    13         ans.emplace_back(i);
    14     for(int i='a';i<='z';++i)
    15         ans.emplace_back(i);
    16     int t;
    17     cin>>t;
    18     while(t--){
    19         int r,c,k;
    20         cin>>r>>c>>k;
    21         int cnt=0;
    22         for(int i=1;i<=r;++i)
    23             for(int j=1;j<=c;++j){
    24                 cin>>a[i][j];
    25                 if(a[i][j]=='R')
    26                     ++cnt;
    27             }
    28         int x=cnt/k,y=cnt%k;
    29         int pt=0;
    30         int tx=x;
    31         if(y)
    32             ++tx,--y;
    33         for(int i=1;i<=r;++i){
    34             if(i&1){
    35                 for(int j=1;j<=c;++j){
    36                     if(a[i][j]=='R')
    37                         --tx,--cnt;
    38                     a[i][j]=ans[pt];
    39                     if(!cnt)
    40                         continue;
    41                     if(!tx){
    42                         ++pt;
    43                         if(y)
    44                             tx=x+1,--y;
    45                         else
    46                             tx=x;
    47                     }
    48                 }
    49             }
    50             else{
    51                 for(int j=c;j>=1;--j){
    52                     if(a[i][j]=='R')
    53                         --tx,--cnt;
    54                     a[i][j]=ans[pt];
    55                     if(!cnt)
    56                         continue;
    57                     if(!tx){
    58                         ++pt;
    59                         if(y)
    60                             tx=x+1,--y;
    61                         else
    62                             tx=x;
    63                     }
    64                 }
    65             }
    66         }
    67         for(int i=1;i<=r;++i){
    68             for(int j=1;j<=c;++j)
    69                 cout<<a[i][j];
    70             cout<<"
    ";
    71         }
    72     }
    73     return 0;
    74 }
    保持热爱 不懈努力 不试试看怎么知道会失败呢(划掉) 世上无难事 只要肯放弃(划掉)
  • 相关阅读:
    Gerrit配置--用户配置
    repo+manifests+git方式管理安卓代码
    FLASH OTP
    Wireshark抓包分析TCP协议
    python 批量修改图片大小
    python 文件查找 glob
    python 统计单词个数
    python 图片上添加数字源代码
    python 删除文件和文件夹
    python 程序列表
  • 原文地址:https://www.cnblogs.com/ldudxy/p/11939198.html
Copyright © 2011-2022 走看看