110,024
社区成员




using System;
using System.Text.RegularExpressions;
class Program
{
static void Main(string[] args)
{
int lenNum = int.Parse(Console.ReadLine());
for (int i = 0; i < lenNum; i++)
{
if (Regex.IsMatch(Console.ReadLine(), "^(?:one|out(?:put)?|in(?:put)?|puton)+$")) Console.WriteLine("YES");
else Console.WriteLine("NO");
}
}
}
using System;
class Program
{
static void Main(string[] args)
{
int lenNum = int.Parse(Console.ReadLine());
for (int i = 0; i < lenNum; i++)
{
if (Console.ReadLine().Replace("one","").Replace("puton","").Replace("output","").Replace("input","").Replace("out","").Replace("in","")=="") Console.WriteLine("YES");
else Console.WriteLine("NO");
}
}
}
using System;
class Program
{
static void Main(string[] args)
{
int lenNum = int.Parse(Console.ReadLine());
for (int i = 0; i < lenNum; i++)
Console.WriteLine(Judge(Console.ReadLine()));
}
static string Judge(string input)
{
int pos = 0;
for (int i = input.Length - 1; i >= 0; i--)
{
pos++;
if (pos == 1||pos==4) continue;
else if (pos == 2)
{
if (input.Substring(i, pos) == "in") pos = 0;
else continue;
}
else if (pos == 3)
{
if (input.Substring(i, pos) == "one" || input.Substring(i, pos) == "out") pos = 0;
else continue;
}
else if (pos == 5)
{
if (input.Substring(i, pos) == "input" || input.Substring(i, pos) == "puton") pos = 0;
else continue;
}
else
{
if (input.Substring(i, pos) == "output") pos = 0;
else return "NO";
}
}
if (pos==0) return "YES";
else return "NO";
}
}
using System;
class Program
{
static void Main(string[] args)
{
int lenNum = int.Parse(Console.ReadLine());
for (int i = 0; i < lenNum; i++)
Console.WriteLine(JudgeInput(Console.ReadLine()));
}
static string JudgeInput(string input)
{
int pos = 0;
for (int i = input.Length - 1; i >= 0; i--)
{
pos++;
switch (input[i])
{
case 'p':
if (pos == 5)
{
if (input.Substring(i, 5) == "puton") pos = 0;
else pos = -1;
}
break;
case 'i':
if (pos==2||pos==5)
{
if(input.Substring(i, pos) == "in"||input.Substring(i, pos) == "input") pos = 0;
else pos = -1;
}
else pos=-1;break;
case 'o':
if (pos == 3)
{
if (input.Substring(i, pos) == "one" || input.Substring(i, pos) == "out") pos = 0;
else pos = -1;
}
else if (pos == 6)
{
if (input.Substring(i, 6) == "output") pos = 0;
else pos = -1;
}
break;
case 'n':
case 'e':
case 't':
case 'u': break;
default: pos = -1; break;
}
if (pos < 0 || pos > 7) return "NO";
}
if (pos==0) return "YES";
else return "NO";
}
}
再扩展一下,是否会更快?
readonly static int[,] numFlag = new int[,]
{
// \r i n p u t o e *
{-1,1,-1,2,-1,-1,3,-1,-1},
{-1,-1,4,-1,-1,-1,-1,-1,-1}, //1:i
{-1,-1,-1,-1,5,-1,-1,-1,-1}, //2;p
{-1,-1,6,-1,7,-1,-1,-1,-1}, //3:o
{0,1,-1,8,-1,-1,3,-1,-1}, //4:in
{-1,-1,-1,-1,-1,9,-1,-1,-1}, //5:pu
{-1,-1,-1,-1,-1,-1,-1,10,-1}, //6:on
{-1,-1,-1,-1,-1,11,-1,-1,-1}, //7:ou
{-1,-1,-1,-1,12,-1,-1,-1,-1}, //8:inp
{-1,-1,-1,-1,-1,-1,13,-1,-1}, //9:put
{0,1,-1,2,-1,-1,3,-1,-1}, //10:one
{0,1,-1,14,-1,-1,3,-1,-1}, //11:out
{-1,-1,-1,-1,-1,15,-1,-1,-1}, //12:inpu
{-1,-1,16,-1,-1,-1,-1,-1,-1}, //13:puto
{-1,-1,-1,-1,17,-1,-1,-1,-1}, //14:outp
{0,1,-1,2,-1,-1,18,-1,-1}, //15:input
{0,1,-1,2,-1,-1,3,-1,-1}, //16:puton
{-1,-1,-1,-1,-1,19,-1,-1,-1}, //17:outpu
{-1,-1,20,-1,7,-1,-1,-1,-1}, //18:inputo
{0,1,-1,2,-1,-1,21,-1,-1}, //19:output
{0,1,-1,2,-1,-1,3,22,-1}, //20:inputon
{-1,-1,23,-1,7,-1,-1,-1,-1}, //21:outputo
{0,1,-1,2,-1,-1,3,-1,-1}, //22:inputone
{0,1,-1,2,-1,-1,3,24,-1}, //23:outputon
{0,1,-1,2,-1,-1,3,-1,-1} //24:outputone
};
readonly static int[] a = { 8, 8, 8, 8, 7, 8, 8, 8, 1, 8, 8, 8, 8, 2, 6, 3, 8, 8, 8, 5, 4, 8, 8, 8, 8, 0 };
#include <stdio.h>
const int a[] = {0,0,0,0,1,0,0,0,2,0,0,0,0,3,4,5,0,0,0,6,7,0,0,0,0,0};
const int b[][8] =
{
// * e i n o p t u
{ 15,15, 7,15, 4,11,15,15 }, // 0
{ 15,15, 7,15, 4, 8,15,15 }, // 1
{ 15,15, 7,15,10,11,15,15 }, // 2
{ 15, 0, 7,15, 4,11,15,15 }, // 3
{ 15,15,15, 5,15,15,15, 6 }, // 4
{ 15, 0,15,15,15,15,15,15 }, // 5
{ 15,15,15,15,15,15, 1,15 }, // 6
{ 15,15,15, 1,15,15,15,15 }, // 7
{ 15,15,15,15,15,15,15, 9 }, // 8
{ 15,15,15,15,15,15, 2,15 }, // 9
{ 15,15,15, 3,15,15,15, 6 }, // 10
{ 15,15,15,15,15,15,15,12 }, // 11
{ 15,15,15,15,15,15,13,15 }, // 12
{ 15,15,15,15,14,15,15,15 }, // 13
{ 15,15,15, 0,15,15,15,15 }, // 14
};
void main()
{
int c, i, n, s;
scanf("%d\n", &n);
for (i = 0; i < n; i++)
{
for (s = 0; (c = getchar()) != 10;)
{
if (s < 15) s = b[s][a[c - 97]];
}
printf(s < 4 ? "YES\n" : "NO\n");
}
}
class Program
{
static void Main()
{
int[,] sJump = new int[,]
{
{-1,0,-100,-1,1,-1,2,3,-1,-1},
{-1,0,-99,-1,-1,4,-1,-1,-1,-1},
{-1,0,-98,-1,-1,5,-1,-1,-1,6},
{-1,0,-97,-1,-1,-1,-1,-1,-1,7},
{-1,1,-96,-1,1,-1,2,8,-1,-1},
{-1,0,-95,9,-1,-1,-1,-1,-1,-1},
{-1,0,-94,-1,-1,-1,-1,-1,10,-1},
{-1,0,-93,-1,-1,-1,-1,-1,11,-1},
{-1,0,-92,-1,-1,-1,-1,-1,-1,12},
{-1,1,-91,-1,1,-1,2,3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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0 };
int lenNum;
bool[] flag;
int currentIndex;
StreamReader sr = new StreamReader(Console.OpenStandardInput());
lenNum = int.Parse(sr.ReadLine());
flag = new bool[lenNum];
for (int i = 0; i < lenNum; i++)
{
flag[i] = true;
currentIndex = 0;
while (currentIndex > -1)
currentIndex = sJump[currentIndex, corresponding[sr.Read()]];
if (currentIndex == -1)
{
flag[i] = false;
sr.ReadLine();
}
else
{
flag[i] = sJump[currentIndex + 100, 1] == 1;
sr.Read();
}
}
for (int i = 0; i < lenNum; i++)
{
if (flag[i])
Console.WriteLine("YES");
else Console.WriteLine("NO");
}
}
}
#include <stdio.h>
#include <stdlib.h>
#define n 10000100
char p[n];
int i, j, k, l, s, f[1001];
const int a[] = {0,0,0,0,1,0,0,0,2,0,0,0,0,3,4,5,0,0,0,6,7,0,0,0,0,0};
const int b[13][8] =
{
// * e i n o p t u
{ -1, 1,-1, 3,-1,-1, 7,-1 }, // 0
{ -1,-1,-1, 2,-1,-1,-1,-1 }, // 1
{ -1,-1,-1,-1, 0,-1,-1,-1 }, // 2
{ -1,-1, 0,-1, 4,-1,-1,-1 }, // 3
{ -1,-1,-1,-1,-1,-1, 5,-1 }, // 4
{ -1,-1,-1,-1,-1,-1,-1, 6 }, // 5
{ -1,-1,-1,-1,-1, 0,-1,-1 }, // 6
{ -1,-1,-1,-1,-1,-1,-1, 8 }, // 7
{ -1,-1,-1,-1, 0, 9,-1,-1 }, // 8
{ -1,-1,-1,10,-1,-1,11,-1 }, // 9
{ -1,-1, 0,-1,-1,-1,-1,-1 }, // 10
{ -1,-1,-1,-1,-1,-1,-1,12 }, // 11
{ -1,-1,-1,-1, 0,-1,-1,-1 }, // 12
};
void main()
{
l = fread(p, sizeof(char), n, stdin);
while (p[j] != 10) j++;
for (i = l - 2; i >= j; i--)
{
if (p[i] == 10)
{
f[k++] = s;
s = 0;
}
else if (s >= 0) s = b[s][a[p[i] - 97]];
}
for (k--; k >= 0; k--)
{
printf(!f[k] ? "YES\n" : "NO\n");
}
}
using System;
using System.IO;
class Timus1102
{
readonly static int[] a = {0,0,0,0,1,0,0,0,2,0,0,0,0,3,4,5,0,0,0,6,7,0,0,0,0,0};
readonly static int[,]b =
{
// * e i n o p t u
{ -1, 1,-1, 3,-1,-1, 7,-1 }, // 0
{ -1,-1,-1, 2,-1,-1,-1,-1 }, // 1
{ -1,-1,-1,-1, 0,-1,-1,-1 }, // 2
{ -1,-1, 0,-1, 4,-1,-1,-1 }, // 3
{ -1,-1,-1,-1,-1,-1, 5,-1 }, // 4
{ -1,-1,-1,-1,-1,-1,-1, 6 }, // 5
{ -1,-1,-1,-1,-1, 0,-1,-1 }, // 6
{ -1,-1,-1,-1,-1,-1,-1, 8 }, // 7
{ -1,-1,-1,-1, 0, 9,-1,-1 }, // 8
{ -1,-1,-1,10,-1,-1,11,-1 }, // 9
{ -1,-1, 0,-1,-1,-1,-1,-1 }, // 10
{ -1,-1,-1,-1,-1,-1,-1,12 }, // 11
{ -1,-1,-1,-1, 0,-1,-1,-1 }, // 12
};
const int n = 10000100;
static void Main()
{
bool[] f = new bool[1001];
Stream r = Console.OpenStandardInput();
byte[] p = new byte[n];
int j, k = 0, l = r.Read(p, 0, n);
for (j = 0; p[j] != 13; j++);
for (int s = 0, i = l - 3; i > j; i--)
{
if (p[i] == 10)
{
f[k++] = s == 0;
i--;
s = 0;
}
else if (s >= 0) s = b[s, a[p[i] - 97]];
}
for (k--; k >= 0; k--)
{
Console.WriteLine(f[k] ? "YES" : "NO");
}
}
}