-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
100 lines (90 loc) · 2.34 KB
/
Copy pathmain.cpp
File metadata and controls
100 lines (90 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <stdio.h>
#define TOUPPER(x) (x>96 ? x-32:x)
#define ISUPPER(x) (x<91 ? 1:0)
#define ISLOWER(x) (x>96 ? 1:0)
int scan(char* x)
{
int i,lastUpper;
register char c = getchar_unlocked();
*x = 0;
for(; !(((c>64)&&(c<91)) || ((c>96)&&(c<123)));c = getchar_unlocked());
for(; (((c>64)&&(c<91)) || ((c>96)&&(c<123)));c = getchar_unlocked())
{
*(x+i) = c;
if(ISUPPER(c))
{
lastUpper == i;
}
i++;
}
*(x+i) = '\0';
return lastUpper;
}
int main()
{
int q,i,j,lA;
int currA,currB;
char a[1001], b[1001];
char done = 0;
scanf ("%d",&q);
for (i=0;i<q;i++)
{
lA = scan(a);
scan(b);
currB = 0;
currA = -1;
for (j=0;a[j]!='\0';j++)
{
if(currA == -1)
{
if(b[currB] == TOUPPER(a[j]))
{
currA = j;
currB++;
if(b[currB] == '\0')
{
if (j >= lA)
{
done = 1;
break;
}
else
{
j = currA;
currA = -1;
currB = 0;
continue;
}
}
continue;
}
}
if(ISUPPER(a[j]) && (b[currB] != TOUPPER(a[j])))
{
j = currA;
currA = -1;
currB = 0;
continue;
}
if((b[currB] == TOUPPER(a[j]))
{
currB ++;
if(b[currB] == '\0')
{
if (j >= lA)
{
done = 1;
break;
}
else
{
j = currA;
currA = -1;
currB = 0;
continue;
}
}
}
}
}
}