QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#567772#9313. Make MaxlanhuoCompile Error//C++171.4kb2024-09-16 13:51:242024-09-16 13:51:24

Judging History

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

  • [2024-09-18 15:56:24]
  • hack成功,自动添加数据
  • (/hack/836)
  • [2024-09-16 13:51:24]
  • 评测
  • [2024-09-16 13:51:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize(2)
//#pragma GCC optimize(3,"Ofast","inline")
typedef long long ll;
#define pll pair<ll,ll>
const int inf=0x3f3f3f3f;
const int N=2e5+5;
const int mod=99844854;
#define PI 3.1415926
#define fi first
#define se second
struct st{
	ll l,r,ma,len;
};
ll n,a[N],ans;
st x;
void check(){
	while(x.r<=n){
		if(x.l==1){
			if(x.r==n)return;
			if(x.ma<a[x.r+1]){
				ans+=len;
				x.r++;
				x.ma=a[x.r];
				len++;
			}
			else if(x.ma==a[x.r+1]){
				x.r++;
				len++;
			}
			else{
				st p=x;
				x.r++;
				x.l=x.r;
				x.ma=a[x.r];
				check();
				x.l=p.l;x.ma=p.ma;
			}
		}
		else{
			if(x.r==n){
				ans+=x.r-x.l+1;
				return;
			}
			else{
				if(x.ma==a[x.r+1]){
					x.r++;
				}
				else if(x.ma>a[x.r+1]){
					st p=x;
					x.l=x.r=(x.r+1);
					x.ma=a[x.r];
					check();
					x.l=p.l;x.ma=p.ma;
				}
				else{
					if(a[x.r+1]==a[x.l-1]){
						x.r++;
					}
					else if(a[x.r+1]>a[x.l-1]){
						ans+=x.r-x.l+1;
						a[x.r]=a[x.l-1];
						return;
					}
					else{
						ans+=x.r-x.l+1;
						x.r++;x.ma=a[x.r];
					}
				}
			}
		}
	}
}
void solve(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	ans=0;
	x={1,1,a[1],1};
	check();
	cout<<ans<<endl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;cin>>t;
    while(t--){
    	solve();
	}
    return 0;
}

詳細信息

answer.code: In function ‘void check()’:
answer.code:23:38: error: ‘len’ was not declared in this scope
   23 |                                 ans+=len;
      |                                      ^~~
answer.code:30:33: error: ‘len’ was not declared in this scope
   30 |                                 len++;
      |                                 ^~~