0分代码求助!
查看原帖
0分代码求助!
838777
a11451419198102333楼主2024/10/14 13:31
#include<bits/stdc++.h>
using namespace std;
#define int long long
int Random(int x)
{
	return rand() % x;
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	srand(time(0));
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	getline(cin, s);
	int End = s.size();
	s = " " + s + "  ";
	int pos = 0;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		pos += x;
		if(pos > End)
		pos = End;
		if(s[pos] == '>')
		{
			if(s[pos + 1] == '>' && s[pos + 2] == '>')
			{
				while(s[pos] == '>')
				{
					pos++;
				}
				if(pos > End)
				pos = End;
			}
		}
		else if(s[pos] == '*')
		{
			if(s[pos + 1] == '*' && s[pos + 2] == '*')
			{
				int k = 0;
				while(s[pos + k] == '*')
				{
					k++;
				}
				pos -= k;
				if(pos < 1)
				pos = 1;
			}
		}
	}
	cout << pos << " " << End - pos << endl;
	return 0;
}
2024/10/14 13:31
加载中...