奇怪的格式错误
  • 板块P2814 家谱
  • 楼主Crane_NF
  • 当前回复5
  • 已保存回复5
  • 发布时间2023/4/30 18:19
  • 上次更新2023/10/23 17:07:16
查看原帖
奇怪的格式错误
286571
Crane_NF楼主2023/4/30 18:19

一本通提交是格式错误 洛谷是 Wrong Answer.wrong answer On line 1 column 7, read(ASCII 13), expected .

#include<bits/stdc++.h>
using namespace std;
const int N=5e4+10;
string name[N];
map <string,int> nb;
int bcj[N],idx;
int find(int x)
{
	if(bcj[x]==x)
		return x;
	return bcj[x]=find(bcj[x]);
}
int main()
{
//	freopen("co","w",stdout);
	for(int i=1;i<N;i++)
		bcj[i]=i;
	char t,t1;
	string t2,t3,tt="-"; 
	while((t=getchar())!='$')
	{
		if(t=='#')
		{
			getline(cin,t2);
			if(nb[t2]==0)
			{
				name[++idx]=t2;
				nb[t2]=idx;
			}
		}
		else if(t=='+')
		{
			getline(cin,t3); 
			if(nb[t3]==0)
			{
				name[++idx]=t3;
				nb[t3]=idx;
			}
			int xx=find(nb[t2]);
			int yy=find(nb[t3]);
			if(xx!=yy)
				bcj[yy]=xx;
		}
		else
		{
			getline(cin,t3);
			cout<<t3<<" "<<name[find(nb[t3])]<<'\n';
//			if(tt!="-")
//				cout<<tt<<'\n';
//			tt=t3;
//			tt+=" ";
//			tt+=name[find(nb[t3])];
		}
	}
	cout<<tt;
	return 0;
}

求助!!

2023/4/30 18:19
加载中...