zoukankan      html  css  js  c++  java
  • CF Round #426 (Div. 2) The Useless Toy 思维 水题

      题目链接: http://codeforces.com/contest/834/problem/A

      题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理

      解题思路: 长度模4, 因为我们只关心起始和结尾, 然后判断

      代码: 

    #include <iostream>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <map>
    #include <iterator>
    using namespace std;
    
    map<char, char> CW;
    map<char, char> CCW;
    map<char, char>::iterator it;
    typedef long long ll;
    int main() {
        CW.insert(make_pair('^', '>'));
        CW.insert(make_pair('>', 'v'));
        CW.insert(make_pair('v', '<'));
        CW.insert(make_pair('<', '^'));
        for( it = CW.begin(); it != CW.end(); it++ ) {
            CCW.insert(make_pair(it->second, it->first));
        }
        char st, ed;
        ll dur;
        while( cin  >> st >> ed ) {
            
            cin >> dur;
            
            dur %= 4;
            if( dur == 2 || dur == 0 ) {
                printf( "undefined
    " );
            }
            else {
                if( dur == 1 ) {
                    if( CW[st] == ed ) {
                        printf( "cw
    " );
                    }
                    else if( CCW[st] == ed ) {
                        printf( "ccw
    " );
                    }
                    else {
                        printf( "undefined
    " );
                    }
                }
                else {
                    if( CW[st] == ed ) {
                        printf( "ccw
    " );
                    }
                    else if( CCW[st] == ed ) {
                        printf( "cw
    " );
                    }
                    else {
                        printf( "undefined
    " );
                    }
                }
            }
        }
        return 0;
    }
    View Code

      思考: 没啥可说的, 水题

  • 相关阅读:
    乐理学习
    hashtable
    vim配置
    SSH & Git
    Java实现单向链表反转
    Java实现二叉树遍历
    Mysql主从配置
    使用VirtualBox虚拟机搭建局域网
    Nginx配置try_files实践一
    Maven package打包webapp项目遇到的问题
  • 原文地址:https://www.cnblogs.com/FriskyPuppy/p/7262201.html
Copyright © 2011-2022 走看看