Codeforces 689A. Mike and Cellphone(模拟)

来源:互联网 发布:吉诺比利职业生涯数据 编辑:程序博客网 时间:2024/06/06 00:50

题目链接

简单题意

给出在手机键盘上的操作路径(按键顺序),问这个操作路径是否唯一,能否平移得到另一种按键顺序。

思路

模拟就好了,但是要注意,因为0的那一列有四个数,要小心处理,最后就是栽在这上面了。

代码

#include <iostream>using namespace std;int num[15] = {0};int main(){    int n;    cin >>n;    string str;    cin >> str;    bool f = false,f1 = false,f2 = false;    for(int i = 0 ; i < n ; i ++){        num[str[i] - '0'] = 1;    }    if((num[1] || num[2] || num[3]) && num[0]) f = true;    if((num[1] || num[2] || num[3]) && (num[7] || num[9])) f1 = true;    if((num[1] || num[4] || num[7]) && (num[3] || num[6] ||num[9])) f2 = true;    if((f1&&f2) || f) cout << "YES" <<endl;    else cout << "NO" <<endl;}
0 0
原创粉丝点击