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\n" ); } else { if( dur == 1 ) { if( CW[st] == ed ) { printf( "cw\n" ); } else if( CCW[st] == ed ) { printf( "ccw\n" ); } else { printf( "undefined\n" ); } } else { if( CW[st] == ed ) { printf( "ccw\n" ); } else if( CCW[st] == ed ) { printf( "cw\n" ); } else { printf( "undefined\n" ); } } } } return 0; }
思考: 没啥可说的, 水题
posted on 2017-07-31 11:23 FriskyPuppy 阅读(137) 评论(0) 编辑 收藏 举报