zoukankan      html  css  js  c++  java
  • 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛 G 旋转矩阵 【模拟】

    链接:https://www.nowcoder.com/acm/contest/90/G
    来源:牛客网

    时间限制:C/C++ 1秒,其他语言2秒
    空间限制:C/C++ 32768K,其他语言65536K
    64bit IO Format: %lld
    题目描述

    景驰公司自成立伊始,公司便将“推动智能交通的发展,让人类的出行更安全,更高效,更经济,更舒适”作为公司使命,通过产业融合、建设智能汽车出行行业的方式,打造“利国、利民、利公司、利个人”的无人驾驶出行系统。公司的愿景是成为中国第一、世界一流的智能出行公司。
    有一天,景驰公司的工程师在真车上做测试。
    景驰公司的试验车上面有一个奇怪的图案,这是一个n*m的矩阵,这辆车可以到处开,每次可以左旋右旋,小明想知道转完之后的图案是怎么样的
    具体来说:有一个n*m的字符矩阵,只包含3种字符(‘+’‘-’,‘|’),通过一通乱旋之后变成什么样子?
    输入描述:

    第一行测试样例数T(0

    #include <cstdio>
    #include <cstring>
    #include <ctype.h>
    #include <cstdlib>
    #include <cmath>
    #include <climits>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <deque>
    #include <vector>
    #include <queue>
    #include <string>
    #include <map>
    #include <stack>
    #include <set>
    #include <numeric>
    #include <sstream>
    #include <iomanip>
    #include <limits>
    
    #define CLR(a) memset(a, 0, sizeof(a))
    #define pb push_back
    
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef pair <int, int> pii;
    typedef pair <ll, ll> pll;
    typedef pair<string, int> psi;
    typedef pair<string, string> pss;
    
    const double PI = 3.14159265358979323846264338327;
    const double E = exp(1);
    const double eps = 1e-6;
    
    const int INF = 0x3f3f3f3f;
    const int maxn = 1e5 + 5;
    const int MOD = 1e9 + 7;
    
    int main()
    {
        int t;
        cin >> t;
        map <char, int> M;
        M['L'] = 3;
        M['R'] = 1;
        map <char, char> q;
        q['|'] = '-';
        q['-'] = '|';
        q['+'] = '+';
        while (t--)
        {
            int n, m;
            scanf("%d%d", &n, &m);
            string s[31];
            for (int i = 0; i < n; i++)
                cin >> s[i];
            string vis;
            cin >> vis;
            int len = vis.size();
            int dir = 0;
            for (int i = 0; i < len; i++)
                dir += M[vis[i]];
            if (dir % 4 == 0)
            {
                printf("%d %d
    ", n, m);
                for (int i = 0; i < n; i++)
                    cout << s[i] << endl;
            }
            else if (dir % 4 == 1)
            {
                printf("%d %d
    ", m, n);
                for (int i = 0; i < m; i++)
                {
                    for (int j = n - 1; j >= 0; j--)
                        cout << q[s[j][i]];
                    cout << endl;
                }
            }
            else if (dir % 4 == 2)
            {
                printf("%d %d
    ", n, m);
                for (int i = n - 1; i >= 0; i--)
                {
                    for (int j = m - 1; j >= 0; j--)
                        cout << s[i][j];
                    cout << endl;
                }
            }
            else if (dir % 4 == 3)
            {
                printf("%d %d
    ", m, n);
                for (int i = m - 1; i >= 0; i--)
                {
                    for (int j = 0; j < n; j++)
                        cout << q[s[j][i]];
                    cout << endl;
                }
            }
                cout << endl;
        }
    }
  • 相关阅读:
    Qt学习之路1---软件下载安装及工程简介
    c++之五谷杂粮---3
    c++之五谷杂粮---2
    隐式类型转换
    运算时的数据类型提升
    c++之五谷杂粮---1
    RSYNC--数据迁移、备份
    microsoft .netframework Available Source Code Components
    查看一个文件系统所在的卷组方法
    IE7/8浏览器都不能显示PNG格式图片
  • 原文地址:https://www.cnblogs.com/Dup4/p/9433209.html
Copyright © 2011-2022 走看看