-
Notifications
You must be signed in to change notification settings - Fork 22
/
0064.cpp
40 lines (38 loc) · 941 Bytes
/
0064.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
// 0064.MP3光标位置
#include <iostream>
using namespace std;
int main()
{
int n;
string s;
while(cin >> n >> s)
{
int idx = 1, jdx = 1;
int maxj = min(n, 4);
for(int i = 0; i < s.size(); i++)
{
if (s[i] == 'U') {
if(idx == 1 && jdx == 1) {
idx = n;
jdx = maxj;
} else {
idx --;
if(jdx != 1) jdx --;
}
} else {
if(idx == n && jdx == maxj) {
idx = 1;
jdx = 1;
} else {
idx ++;
if(jdx != maxj) jdx ++;
}
}
}
int now = idx;
for( ; jdx != 1; jdx --) idx --;
for(int i = 0; i < maxj; i++) cout << idx+i << ' ';
cout << endl << now << endl;
}
return 0;
}