-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12662 - Good Teacher.cpp
103 lines (93 loc) · 2.12 KB
/
12662 - Good Teacher.cpp
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
101
102
103
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
string s[100];
for(int i = 0; i < n; i++)
{
cin >> s[i];
}
//cout<<s<< endl;
int q;
cin >> q;
while(q--)
{
int p;
cin >> p;
p = p - 1;
if(s[p] != "?")
{
cout<< s[p]<< endl;
continue;
}
int cnt1 = 0, cnt2 = 0, f1 = 0, f2 = 0;
string ch1, ch2;
for(int i = p; i < n; i++)
{
if(s[i] != "?"){
ch1 += s[i];
break;
}
cnt1++;
if(i == n-1){
f1= 1;
break;
}
}
for(int i = p; i >= 0; i--)
{
if(s[i] != "?"){
ch2 += s[i];
break;
}
cnt2++;
if(i == 0){
f2 = 1;
break;
}
}
//cout<<ch1 << " " << cnt1 << " " << ch2 << " " << cnt2 << endl;
if(cnt1 == 0 || f1)
{
for(int i = 0; i < cnt2; i++)
{
cout<<"right of ";
}
cout<<ch2 << endl;
}
else if(cnt2 == 0 || f2)
{
for(int i = 0; i < cnt1; i++)
{
cout<<"left of ";
}
cout<<ch1 << endl;
}
else if(cnt1 == cnt2)
{
cout<<"middle of "<<ch2<<" and "<<ch1<< endl;
}
else if(cnt1 < cnt2)
{
for(int i = 0; i < cnt1; i++)
{
cout<<"left of ";
}
cout<< ch1<< endl;
}
else
{
for(int i = 0; i < cnt2; i++)
{
cout<<"right of ";
}
cout<<ch2<< endl;
}
//cout<<s<< endl;
}
}
return 0;
}