QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#593846#6968. 守卫_TLEer_Compile Error//C++14615b2024-09-27 16:24:252024-09-27 16:24:26

Judging History

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

  • [2024-09-27 16:24:26]
  • 评测
  • [2024-09-27 16:24:25]
  • 提交

answer

#include<bits/stdc++.h>
#define eps 1e-7
using namespace std;
int dp[5010][5010],n,h[5010],ans;
#define seek(p,a,b) ((double)(1)*(h[p]-h[a])/(p-a)>(double)(1)*(h[p]-h[b])/(p-b))
signed main(){
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=1;i<=n;i++){
		dp[i][i]=1;ans^=1;
		int sigm=1,lst=0
		for(int j=i-1;j>=1;j--){
			if(!lst)lst=j;
			else if(seek(i,lst,j))
				sigm+=min(dp[j+1][lst],dp[j+1][lst-1]),lst=j;
			dp[j][i]=sigm+min(dp[j][lst],dp[j][lst-1]);
			ans^=dp[j][i];
		}
	}
	cout<<ans<<'\n';
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:14:17: error: expected ‘,’ or ‘;’ before ‘for’
   14 |                 for(int j=i-1;j>=1;j--){
      |                 ^~~
answer.code:14:31: error: ‘j’ was not declared in this scope
   14 |                 for(int j=i-1;j>=1;j--){
      |                               ^