求助,为什么全是RE
查看原帖
求助,为什么全是RE
661913
liwenxi1145144444楼主2023/10/2 11:29
#include<bits/stdc++.h>
using namespace std;
int n,ans;
map<string,string> a;
int main(){
	cin>>n;
	n++;
	while(n--){
		string s;
		getline(cin,s);
		if(s[6]==' '){
			string tm="";
			int i=7;
			for(i=7;s[i]!='(';i++){
				tm+=s[i];
			}
			if(s[i+1]=='"'){
				string tmp="";
				for(int j=i+2;s[j]!='"';j++){
					tmp+=s[j];
				}
				a[tm]=tmp;
				ans+=tmp.size();
			}else{
				string tmp="";
				for(int j=i+1;s[j]!=')';j++){
					tmp+=s[j];
				}
				a[tm]=a[tmp];
				ans+=a[tmp].size();
			}
		}else{
			string tm="";
			int i=12;
			for(i=12;s[i]!='(';i++){
				tm+=s[i];
			}
			if(s[i+1]=='"'){
				string tmp="";
				for(int j=i+2;s[j]!='"';j++){
					tmp+=s[j];
				}
				a[tm]=tmp;
			}else{
				string tmp="";
				for(int j=i+1;s[j]!=')';j++){
					tmp+=s[j];
				}
				a[tm]=a[tmp];
			}
		}
	}
	cout<<ans;
	return 0;
} 
2023/10/2 11:29
加载中...