Codeforces Mike and Cellphone
#include<bits/stdc++.h>
#define sf scanf
#define pf printf
using namespace std;
int main()
{
int n;
char ch[11];
while(~sf("%d", &n))
{
getchar();
int i=0;
for(i=0; i<n; i++)
{
sf("%c",&ch[i]);
}
int up=1, right=1, left=1, down=1;
for(i=0; i<n; i++)
{
int tmp = ch[i] - 48;
if(tmp==1 or tmp==2 or tmp==3) up=0;
if(tmp==1 or tmp==4 or tmp==7) left=0;
if(tmp==3 or tmp==6 or tmp==9) right=0;
if(tmp==7 or tmp==9) down=0;
if(tmp==0) down=0, left=0, right=0;
}
if(up==1 or right==1 or left==1 or down==1) cout << "NO\n";
else cout << "YES\n";
}
return 0;
}
#define sf scanf
#define pf printf
using namespace std;
int main()
{
int n;
char ch[11];
while(~sf("%d", &n))
{
getchar();
int i=0;
for(i=0; i<n; i++)
{
sf("%c",&ch[i]);
}
int up=1, right=1, left=1, down=1;
for(i=0; i<n; i++)
{
int tmp = ch[i] - 48;
if(tmp==1 or tmp==2 or tmp==3) up=0;
if(tmp==1 or tmp==4 or tmp==7) left=0;
if(tmp==3 or tmp==6 or tmp==9) right=0;
if(tmp==7 or tmp==9) down=0;
if(tmp==0) down=0, left=0, right=0;
}
if(up==1 or right==1 or left==1 or down==1) cout << "NO\n";
else cout << "YES\n";
}
return 0;
}
Comments
Post a Comment