ABC352

xinyimama發表於2024-05-05

A

link

\(x\)停不到,\(y\)能停到。
要先判斷是從前往後還是從後往前。

點選檢視程式碼
#include<bits/stdc++.h>

using namespace std;

signed main(){
	
	int n,x,y,z;
	cin >> n >> x >> y >> z;
	
	if(x <= y){
		if(z > x&&z <= y) cout << "Yes";
		else cout << "No";
	}
	else{
		if(z < x&&z >= y) cout << "Yes";
		else cout << "No";
	}
	
	return 0;
	
}

B

link

兩個指標,分別指向\(S\)\(T\),如果當前兩個指標指向的位置一樣,輸出這個位置,否則把指向\(T\)的指標加一。

點選檢視程式碼
#include<bits/stdc++.h>

using namespace std;

char s[200005];
char t[200005];

signed main(){
	
	cin >> s+1 >> t+1;
	
	int n = strlen(t+1);
	
	for(int i = 1,j = 1;i <= n;++ i,++j){
		while(t[i] != s[j]) ++i;
		cout << i << " ";
	}
	
	return 0;
	
}

C

link

他要求的本質上就是前面所有的肩膀高度加最後一個的頭高