题解 | 特殊城市

特殊城市

https://www.nowcoder.com/practice/46f68af83db74b709a788dedb656c5f9

#include<bits/stdc++.h>
using namespace std;

int n;

multiset<string> mst;

int main(){
	
	cin>>n;
	
	string name,zhou;
	int res=0;
	for(int i=1;i<=n;i++){
		cin>>name>>zhou;
		name=name.substr(0,2);
		string p=name+zhou;
		if(name==zhou) continue;
		res+=mst.count(p);
		string temp=zhou+name;
		mst.insert(temp);
	}
	cout<<res<<endl;
    return 0;
}


全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务