跳到正文

个人记录

2026.1.28 T3

linzeyu2012约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年1月28日
收录
2026年1月28日
更新
2026年11月11日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1
C++
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void sol(){
	string s;
	cin>>s;
	int n=s.size();
	s=' '+s;
	bool check=1;
	for(char i:s){
		if(i=='-'){
			check=0;
			break;
		}
	}
	string lst=s.substr(n-2,3);
	if(check||s[1]=='-'||lst!=">>>") return cout<<"No\n",void();
	int las=n,tot=0;
	vector<pair<int,int> > res;
	for(int i=n;i>2;i--){
		string t=s.substr(i-2,3);
		if(t==">>>") tot++,las=i,res.push_back(make_pair(1,i));
		else break;
	}
	for(int i=2;i<=las-4;i++){
		if(s[i]=='>') tot++,res.push_back(make_pair(i,las-i+1));
	}
	cout<<"Yes "<<tot<<"\n";
	for(pair<int,int> elem:res) cout<<elem.first<<" "<<elem.second<<"\n";
}
int main(){
	int t;
	cin>>t;
	while(t--) sol();
	return 0;
}
原文