超时
查看原帖
超时
537655
XmosCao楼主2024/7/3 22:11

下面这个代码为什么我开O2优化可以满分,不开O2会WA88个点呢

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int A=10004;
const int B=30;
const int T=3;
ll n,t,a,b,ans[A][B];
string oput[T]={"Masha","Stas","Missing"};
ll dfs(ll x,ll y){
	if(x==1&&y>27){
		return 2;
	}
	if(y==1&&x>n/x){
		if((n-x)&1){
			return 0;
		}else{
			return 1;
		}
	}
	if(ans[x][y]){
		return ans[x][y];
	}
	if(n<pow(x,y)){
		return 0;
	}
	for(long long i=1;i<=10000000;i++)
	{
	    
	}
	ll tx=dfs(x+1,y);
	ll ty=dfs(x,y+1);
	if(!tx&&!ty){
		return ans[x][y]=1;
	}
	if(tx==1||ty==1){
		return ans[x][y]=0;
	}
	return ans[x][y]=2;
}
int main(){
	cin>>n>>t;
	ans[1][27]=2;
	for(int i=1;i<=t;i++){
		cin>>a>>b;
		cout<<oput[dfs(a,b)]<<'\n';
	}
	return 0;
}
2024/7/3 22:11
加载中...