QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#351419#5035. foo~xuqinCompile Error//C++141.4kb2024-03-11 21:52:412024-03-11 21:52:42

Judging History

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

  • [2024-03-11 21:52:42]
  • 评测
  • [2024-03-11 21:52:41]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
const int maxn=6e5+10;
const int inf=2e9;

inline int read() {
	int x=0, f=1; char c=getchar();
	for(; c<'0'||c>'9'; c=getchar()) if(c=='-') f=0;
	for(; c>='0'&&c<='9'; c=getchar()) x=x*10+c-'0';
	return f?x:-x; 
} 

int a[maxn<<1];
int st[maxn];
int f[maxn], g[maxn], n, dep[maxn];

int suf[maxn];
inline void SOL() {
	for(int i=1; i<=n; ++i) g[i]=f[i], f[i]=-inf;
	
	int tp=1; st[1]=n;
	suf[1]=0; dep[n]=1;
	for(int i=n-1; i>0; --i) {
		while(tp&&a[i]>a[st[tp]]) {
			suf[tp-1]=max(suf[tp-1], suf[tp]+1);
			--tp;
		}
		dep[i]=dep[st[tp]]+1;
		f[i]=suf[tp]+dep[i];
		st[++tp]=i; suf[tp]=max(suf[tp-1], g[i]-dep[i]);
	}
l
	///
}
int b[maxn];
inline void sol(int k) {
	for(int i=1; i<=n; ++i) a[i]=a[i+n]=b[i];
	for(int i=n+1; i<=n+n; ++i) if(a[i]==n) {
		for(int j=1; j<=n; ++j) a[j]=a[j+i-n];
		break;
	}
	int tp=1; st[1]=n; dep[n]=1; 
	for(int i=n-1; i>0; --i) {
		while(tp&&a[i]>a[st[tp]]) --tp;
		dep[i]=dep[nxt[i]]+1;
		st[++tp]=i;
	}
	for(int i=1; i<=n; ++i) f[i]=dep[i]; 
	for(int i=2; i<=k; ++i) SOL();
	int ans=0;
	for(int i=1; i<=n-k+1; ++i) ans=max(ans, f[i]);
	return ans+1;
}
int main() {
	n=read(); int k=read();
	for(int i=1; i<=n; ++i) b[i]=read();
	int ans=sol(k);
	reverse(a+1, a+n+1);
	ans=max(ans, sol(k));
	printf("%d", ans);	
	return 0;
}

詳細信息

answer.code: In function ‘void SOL()’:
answer.code:35:1: error: ‘l’ was not declared in this scope
   35 | l
      | ^
answer.code: In function ‘void sol(int)’:
answer.code:48:28: error: ‘nxt’ was not declared in this scope
   48 |                 dep[i]=dep[nxt[i]]+1;
      |                            ^~~
answer.code:55:19: error: return-statement with a value, in function returning ‘void’ [-fpermissive]
   55 |         return ans+1;
      |                ~~~^~
answer.code: In function ‘int main()’:
answer.code:60:20: error: void value not ignored as it ought to be
   60 |         int ans=sol(k);
      |                 ~~~^~~
answer.code:62:25: error: invalid use of void expression
   62 |         ans=max(ans, sol(k));
      |                      ~~~^~~