标签:nsis 不能 html title ext std length element ati
Time Limit: 2 sec / Memory Limit: 1024 MB
ps:我的vector需要加强,用错了。
We have a string SS of length N consisting of R
, G
, and B
.
Find the number of triples (i, j, k) (1≤i<j<k≤N) that satisfy both of the following conditions:
R
, G
, and B
.Input is given from Standard Input in the following format:
N S
Print the number of triplets in question.
4 RRGB
1
Only the triplet (1, 3, 4)(1, 3, 4) satisfies both conditions. The triplet (2, 3, 4)(2, 3, 4) satisfies the first condition but not the second, so it does not count.
39 RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB
1800
#include<bits/stdc++.h> using namespace std; #define ll long long #define rep(i,n) for(int i=0;i<n;i++) #define repr(i,n) for(int i=n-1;i>=0;i--) const int N=2e5; int a[4005],b[4005],c[4005];//若改为vector<int>a,b,c错误,vector不能达成a[i]用法 int main(){ int n,l=0,m=0,r=0; ll ans=0; string s; cin>>n>>s; rep(i,n){ if(s[i]==‘R‘) a[l++]=i+1; if(s[i]==‘G‘) b[m++]=i+1; if(s[i]==‘B‘) c[r++]=i+1; } for(int i=0;i<l;i++) for(int j=0;j<m;j++){ int sum=r; int a1=min(a[i],b[j]); int b1=max(a[i],b[j]); if(2*a1-b1-1>=0&&2*a1-b1-1<n&&s[2*a1-b1-1]==‘B‘) sum--; if(2*b1-a1-1>=0&&2*b1-a1-1<n&&s[2*b1-a1-1]==‘B‘) sum--; if((a1+b1)%2==0&&s[(a1+b1)/2-1]==‘B‘) sum--; ans+=sum; //cout<<ans<<endl; } cout<<ans<<endl; return 0; }
标签:nsis 不能 html title ext std length element ati
原文地址:https://www.cnblogs.com/asunayi/p/12700262.html