---
# System prepended metadata

title: YTP

---

# YTP

pA    
```cpp= 
#include <bits/stdc++.h>

using namespace std;

int main()
{

    int y=0,t=0,p=0;
    string a;

    while(getline(cin,a)){
        for(int i=0;i<a.length();i++){
        if(a[i]=='y'||a[i]=='Y'){
            y++;
        }else if(a[i]=='t'||a[i]=='T'){
            t++;
        }else if (a[i]=='p'||a[i]=='P'){
            p++;
        }
    }


    }

    int b;
    b=min(p,min(y,t));
    cout << b  <<'\n'  ;
    return 0;
}
```
pB
```cpp=
#include <bits/stdc++.h>

using namespace std;

int main()
{
    double v1,v2,t,theta,beta,theta1,beta1;
    scanf("%lf,%lf,%lf,%lf" ,&v1,&v2,&theta,&beta);
    theta1=atan(v1);
    beta1=atan(v2/sqrt(v1*v1+1));
    t=sqrt(v1*v1+v2*v2+1);
    v1=t*cos(beta1+beta)*sin(theta+theta1);
    v2=t*sin(beta1+beta);
    cout <<fixed<<setprecision(2)<< t  <<","<<v1 << ","<<v2<<'\n' ;
    return 0;
}

```
pC
```cpp=
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define mem(a) memset(a,0,sizeof(a))
#define inf INT_MAX
#define mod 1000000009
#define MAXN 1000005
int n,m,x,ans;
//-----------------------------------
int a[MAXN];

void solve(){
    cin >> n >> a[0];
    for(int i=1;i<n;i++){
    	cin >> a[i];
    	ans=(ans*(a[i]-a[i-1]))%mod;
    }
    if(ans<0) ans+=mod;
    cout << ans << '\n';
}

signed main(){
    cin.sync_with_stdio(0),cin.tie(0);
    int N=1;
    //cin >> N;
    while(N--){
        ans=1;
        solve();
    }
}
```
pD
```cpp=
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define mem(a) memset(a,0,sizeof(a))
#define inf INT_MAX
#define mod 1000000007
#define MAXN 105
int n,m,x,ans;
//-----------------------------------


void solve(){
    cin >> m >> n;
    
    int a,ob;
    vector<int> dis(n,1e9);
    for(int i=0;i<m;i++){
    	cin >> a >> ob;
    	a--;
    	for(int pos=a,b=ob;pos>=0;pos--,b++){
    		dis[pos]=min(dis[pos],b);
    	}	
    	for(int pos=a,b=ob;pos<=n;pos++,b++){
    		dis[pos]=min(dis[pos],b);
    	}
    }
    for(int i=0;i<n;i++){
    	cout << dis[i] << ' ';
    }
}

signed main(){
    cin.sync_with_stdio(0),cin.tie(0);
    int N=1;
    //cin >> N;
    while(N--){
        ans=0;
        solve();
    }
}
```
pE
```cpp=
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define mem(a) memset(a,0,sizeof(a))
#define inf INT_MAX
#define mod 1000000007
#define MAXN 100005
int N=1,n,m,x,ans;
//-----------------------------------

void solve(){
    cin >> n >> m;
    for(int i=1;i<min(n,m);i++){
    	int square=(n-i)*(m-i);
    	ans+=square*i*i;
    }
    
    for(int i=1;i<n;i++){
    	for(int j=1;i+j<min(n,m);j++){
    		int square=(n-i-j)*(m-i-j);
    		ans+=square*(i*i+j*j);
    	}
    }
    cout << ans << '\n';
}

signed main(){
    cin.sync_with_stdio(0),cin.tie(0);
    int N=1;
    //cin >> N;
    while(N--){
        ans=0;
        solve();
    }
}
```
pF
```cpp=
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define mem(a) memset(a,0,sizeof(a))
#define inf INT_MAX
#define mod 1000000007
#define MAXN 100005
int N=1,n,m,ans;
//-----------------------------------
int v[MAXN],w[MAXN],x[MAXN],s[MAXN];
bool used[MAXN];

void solve(){
	int W,y;
    cin >> n >> m >> W;
    for(int i=0;i<n;i++) cin >> w[i];
    for(int i=0;i<n;i++) cin >> v[i];
    for(int i=0;i<m;i++) cin >> x[i];
    for(int i=0;i<m;i++) cin >> s[i];
    
    vector<int> dp(W+1);
    for(int i=0;i<m;i++){
    	int ttl_w=-x[i],ttl_v=0;
    	vector<int> item;
    	
    	for(int j=0;j<s[i];j++){
    		cin >> y;
    		y--;
    		
    		ttl_v+=v[y];
    		ttl_w+=w[y];
    		item.pb(y);
    		used[y]=true;
    	}
    	
    	vector<int> a=dp,b=dp;
    	for(int i=W;i>=ttl_w;i--){
    		a[i]=max(a[i],a[i-ttl_w]+ttl_v);
    	}
    	for(auto j:item){
    		for(int i=W;i>=w[j];i--){
    			b[i]=max(b[i],b[i-w[j]]+v[j]);
    		}
    	}
    	for(int i=0;i<=W;i++){
    		dp[i]=max(a[i],b[i]);
    	}
    }
    for(int j=0;j<n;j++){
    	if(!used[j]){
    		for(int i=W;i>=w[j];i--){
    			dp[i]=max(dp[i],dp[i-w[j]]+v[j]);
    		}
    	}
    }
    for(int i=0;i<=W;i++){
    	ans=max(ans,dp[i]);
    }
    cout << ans << '\n';
}

signed main(){
    cin.sync_with_stdio(0),cin.tie(0);
    int N=1;
    //cin >> N;
    while(N--){
        ans=0;
        solve();
    }
}
```
pG
```cpp=
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define mem(a) memset(a,0,sizeof(a))
#define inf INT_MAX
#define mod 1000000007
#define MAXN 200005
int n,m,x,ans;
//-----------------------------------
int pre[MAXN][2],bit[2][MAXN];

void update(int x,int which_one){
	while(x<MAXN){
		bit[which_one][x]++;
		x+=x&-x;
	}
}

int query(int x,int which_one){
	int ans=0;
	while(x>0){
		ans+=bit[which_one][x];
		x-=x&-x;
	}
	return ans;
}

void solve(){
	cin >> n;
    
	vector<pii> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i].F;
		a[i].S=i+1;
	}
	sort(all(a));
	
	for(int i=0;i<n;i++){
		if(a[i].F&1){
			ans+=query(a[i].S-1,1)*(query(n,0)-query(a[i].S,0));
			ans+=query(a[i].S-1,0)*(query(n,1)-query(a[i].S,1));
		}else{
			ans+=query(a[i].S-1,1)*(query(n,1)-query(a[i].S,1));
			ans+=query(a[i].S-1,0)*(query(n,0)-query(a[i].S,0));
		}
		update(a[i].S,a[i].F&1);
	}
	cout << ans << '\n';
}

signed main(){
    cin.sync_with_stdio(0),cin.tie(0);
    int N=1;
    //cin >> N;
    while(N--){
        ans=0;
        solve();
    }
}
```
pH
```cpp=
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define mem(a) memset(a,0,sizeof(a))
#define inf INT_MAX
#define mod 1000000007
#define MAXN 1000005
int n,m,x,ans;
//-----------------------------------
string a[MAXN];

void solve(){
    cin >> n >> m;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int y;
	while(m--){
		cin >> x >> y;
		
		int i;
		for(i=0;i<a[x].size() && i<a[y].size();i++){
			if(a[x][i]!=a[y][i]) break;
		}
		cout << i << '\n';
	}
}

signed main(){
    cin.sync_with_stdio(0),cin.tie(0);
    int N=1;
    //cin >> N;
    while(N--){
        ans=0;
        solve();
    }
}
```
pI
```cpp=

```
我剩最後一題了!!!
不可以這樣子欸，偷刪聊天記錄