QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201297#5158. Interview QuestionPhantomThreshold#WA 7ms27240kbC++201.7kb2023-10-05 13:34:552023-10-05 13:34:55

Judging History

你现在查看的是最新测评结果

  • [2023-10-05 13:34:55]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:27240kb
  • [2023-10-05 13:34:55]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;

int gcd(int a,int b){ return !a?b:gcd(b%a,a); }

const int maxn = 1010000;

int L,R;
int a[maxn],b[maxn],ab[maxn];
int oka[maxn],okb[maxn],okab[maxn];


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>L>>R;
	int lasa=-1,lasb=-1,lasab=-1;
	int A=0,B=0,AB=0;
	for(int i=L;i<=R;i++)
	{
		string str; cin>>str;
		if(str[0]=='F')
		{
			a[i]=1;
			if(str.size()>4) ab[i]=1,b[i]=1;
		}
		if(str[0]=='B')
		{
			b[i]=1;
		}
		
		if(a[i])
		{
			if(lasa!=-1) A=i-lasa;
			lasa=i;
		}
		if(b[i])
		{
			if(lasb!=-1) B=i-lasb;
			lasb=i;
		}
		if(ab[i])
		{
			if(lasab!=-1) AB=i-lasab;
			lasab=i;
		}
	}
	
	if(A==0)
	{
		if(lasa==-1)
		{
			for(int i=1;i<L;i++) oka[i]=1;
			for(int i=R+1;i<maxn;i++) oka[i]=1;
		}
		else
		{
			for(int i=1;i<maxn;i++) if(lasa%i==0 && lasa-i<L && lasa+i>R)
				oka[i]=1;
		}
	}
	else oka[A]=1;
	if(B==0)
	{
		if(lasb==-1)
		{
			for(int i=1;i<L;i++) okb[i]=1;
			for(int i=R+1;i<maxn;i++) okb[i]=1;
		}
		else
		{
			for(int i=1;i<maxn;i++) if(lasb%i==0 && lasb-i<L && lasb+i>R)
				okb[i]=1;
		}
	}
	else okb[B]=1;
	if(AB==0)
	{
		if(lasab==-1)
		{
			for(int i=1;i<L;i++) okab[i]=1;
			for(int i=R+1;i<maxn;i++) okab[i]=1;
		}
		else
		{
			for(int i=1;i<maxn;i++) if(lasab%i==0 && lasab-i<L && lasab+i>R)
				okab[i]=1;
		}
	}
	else okab[AB]=1;
	
	for(int i=1;i<maxn;i++) if(oka[i])
	{
		for(int j=1;j<maxn;j++) if(okb[j])
		{
			int ij=i*j/gcd(i,j);
			if(ij<maxn && okab[ij])
			{
				
			cout<<i<<' '<<j<<endl;
			return 0;
			}
		}
	}
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 5ms
memory: 13984kb

input:

7 11
7 8 Fizz Buzz 11

output:

3 5

result:

ok 

Test #2:

score: 0
Accepted
time: 7ms
memory: 9820kb

input:

49999 50002
49999 FizzBuzz 50001 Fizz

output:

2 4

result:

ok 

Test #3:

score: 0
Accepted
time: 7ms
memory: 11756kb

input:

8 11
Buzz Buzz FizzBuzz Buzz

output:

5 1

result:

ok 

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 27240kb

input:

10 15
10 11 12 13 14 15

output:

1 1

result:

FAIL Mismatch at position 10: expected 10, got FizzBuzz