评测稽和本地跑出来结果不同??!蒟蒻求助
查看原帖
评测稽和本地跑出来结果不同??!蒟蒻求助
218188
ParanoidMO楼主2020/5/18 17:58
#include<bits/stdc++.h>
using namespace std;
long long mod1 = 1e11+7, mod2 = 1e10-7, b=27;

struct node
{
	int t, fp, ap;
};
int cnt;
char s[1000020];
node a;

int main()
{
    a.t = 0;
    a.fp = 0;
    a.ap = 0;
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string as; cin>>as;
	long long ans=0, obj=0, ans1=0, obj1=1;
	for (int i=0; i<as.length(); i++) 
	{
		if ('a' <= as[i] && as[i] <= 'z') as[i] -= 32;
		ans1 = ans1*b + as[i]-'A';
		ans1 %= mod1;
		ans1 %= mod2;
	}
	gets(s);
	int l = strlen(s);
	for (int i=0; i<l; i++)
	{
		if ('a' <= s[i] && s[i] <= 'z') s[i] -= 32;
		if (s[i] != ' ') 
		{
			ans = ans*b + s[i]-'A';
			ans %= mod1;
			ans %= mod2;
		}
		else
		{
		    if (ans1 == ans)
		    {
		        a.t ++;
		        if (a.ap == 0) a.fp = obj, a.ap = 1;
		    }
			ans = 0;
			obj = i+1;
		}
		
	}
    if (ans1 == ans)
	{
	    a.t ++;
	    if (a.ap == 0) a.fp = obj, a.ap = 1;
	}
	if (a.ap != 0)
	{
		cout<<a.t<<" "<<a.fp;
	 } 
	else cout<<-1;
	
}
2020/5/18 17:58
加载中...