1 条题解

  • 0
    @ 2026-1-21 20:33:42
    using namespace std;
    
    //O(n·s)
    
    int main() {
    	ios::sync_with_stdio(false);
    	cin.tie(nullptr);
    	cout.tie(nullptr);
    	int n;
    	cin>>n;
    	for(int i=0;i<n;i++){
    		int s;
    		long long stable=0;
    		cin>>s;
    		string k1;
    		cin>>k1;
    		string k2=k1;
    		reverse(k2.begin(),k2.end());
    		for(int j=0;j<s;j++){
    			if((k1[j]=='C'&&k2[j]=='G')||(k1[j]=='G'&&k2[j]=='C')||
    			   (k1[j]=='A'&&k2[j]=='T')||(k1[j]=='T'&&k2[j]=='A')){
    				stable+=(j+1);
    			}
    			if(k1[j]!='C'&&k1[j]!='G'&&k1[j]!='T'&&k1[j]!='A'){
    				stable=0;
    				break;
    			}
    		}
    		cout<<stable<<"\n";
    	}
    }
    
    
    • 1

    信息

    ID
    9409
    时间
    1000ms
    内存
    512MiB
    难度
    3
    标签
    递交数
    1
    已通过
    1
    上传者